ASP.NET MVC: HttpContext.Current.User.Identity.IsAuthenticated is always false on some virtual machines
I have been going through this weird issue on some of my virtual machines. It works perfectly fine on another!
When user email and password has been verified, I use SetAuthCookie to setup the httpcontext properties.
FormsAuthentication.SetAuthCookie(viewModel.Email, viewModel.RememberMe);
I use
HttpContext.Current.User.Identity.IsAuthenticated;
method to check whether user is authenticated or not but this always returns null on few virtual machines while works perfectly fine on other. Are there any environment setting I am missing? Could anyone please help me to debug/fix this issue.
I figured out that it is returning Identity = Generic on machines where it doesn't work. It should return Identity = Forms as it d开发者_高级运维oes on another machine and also in web.config, the authentication mode is setup to Forms!
Thanks.
This is resolved. I had a domain=".localhost.com" for Forms properties in web config. I have removed it and worked fine!
精彩评论