Reputation: 159
I use classic ASP.NET Membership Provider in my ASP.NET MVC 3 application. When I validate user by Membership.Validate() method, I set the value in FormsAuthentication.SetAuthCookie() for persistent login during the navigation of the web site, but when i try to call the HttpContext.User.Identify.Name i get a String Empty value. Where is the problem?
P.S. In the past, i used the ASP.NET Web Forms Access Controls to do this job that automatize this mecanism.
Upvotes: 2
Views: 132
Reputation: 93424
Are you doing a page refresh? (ie a RedirectToAction?)
The authentication cookie will not be valid until after a full page refresh has occurred. If you check the HttpContext.User.Identity.Name right after you validate the user and set the cookie, this value will be null.
Upvotes: 1