c# - How to use "User.Identity.IsAuthenticated" in Web API -
user.identity.isauthenticated
returns false
in asp.net web api project.
in account apicontroller
have following:
claimsidentity identity = new claimsidentity(claims, defaultauthenticationtypes.applicationcookie); authenticationmanager.signin(new authenticationproperties() { ispersistent = ispersistent }, identity);
after signing in, user.identity.isauthenticated
false
in apicontroller
true
in mvc controller.
it's unable use httpcontext property directly in apicontroiller. , have make use of request property of type system.net.http.httprequestmessage. httprequestmessage has properties dictionary; find value of key ms_userprincipal holds iprincipal object.
Comments
Post a Comment