35 Replies
i get an error in the userId line
This is the error
Im using asp.net identity authentication
also have this if needed
it jsut means there were no claims that matched.
I suggest you place some breakpoints and debug, check if the claim has a different name
or that its present at all
how can i find the claim? @Pobiega
set a breakpoint on the first line, and inspect the
User.Claims
verify what claims the user has
track your problem downhere?
or on the create
var userId = User.Claims.First(c =>$debug
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
this what im looking for?
@Pobiega
almost. you have the claims just above
Identity
what particular data you are after is up to youbut use the debugger to see what is available, then write your code to find the correct values
im after the users id
check the identity claims
something like this? @Pobiega
ah no
i see what you are asking to see
here
should it be actor by any chance
or something like that
this one.
nameidentifier
thats your "user id"so i change UserId for nameidentifier
wellllll
if you just type "nameidentifier" it wont work
you need to use the constant
I think its something like
ClaimNames
isnt it just NameIdentifier?
no
i found a stackoverflow with something like that
its
thats the claim name
that entire thing
ok well il just copy that
Also while we are at it
Im having problem with my unit tests
It only accepted me to make them in version 4.8
and my solution is in 8.0
and now its giving me errors
You probably picked the wrong project type at creation
There are modern .net test templates
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View