What is this cookie called when it gets set? Can I see it in my cookie folder for my browser?
I think it doesn't get set so my login verification fails.
What is this cookie called when it gets set? Can I see it in my cookie folder for my browser?
I think it doesn't get set so my login verification fails.
What is this cookie called when it gets set?
The default name for the cookie is .ASPXAUTH
. It's configurable through the web.config to have any name.
<authentication mode="Forms">
<forms name=".SomeName" loginUrl="Login.aspx" />
</authentication>
So check there for anything non-standard.
Can I see it in my cookie folder for my browser?
You should be able to see it using any browser tools.
Normally, if you create Authentication Cookie yourself, you will need to create Principal object and save it inside Current Thread in AuthenticateRequest event for every request.
Otherwise, when you check User.Identity.IsAuthenticated, it will return false.
public class Global : HttpApplication
{
private void Application_AuthenticateRequest(object sender, EventArgs e)
{
HttpCookie decryptedCookie =
Context.Request.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket ticket =
FormsAuthentication.Decrypt(decryptedCookie.Value);
var identity = new GenericIdentity(ticket.Name);
var principal = new GenericPrincipal(identity, null);
HttpContext.Current.User = principal;
Thread.CurrentPrincipal = HttpContext.Current.User;
}
}
Make sure you have authentication tag in web.config. For example,
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880"/>
</authentication>
public ActionResult Index()
{
var username = User.Identity.Name;
return View();
}
I use EditThisCookie Chrome Plugin.