Monday, April 14, 2008

ASP.NET Login isn't persistent

I've had a problem with the System.Web.UI.WebControls.Login control on a web application. ASP.NET creates a cookie for the login, which is supposed to be psersistent if the "RememberMe" checkbox is selected. The problem is, however, that if you restart your computer, the cookie is deleted, and you have to login again... I decided to investigate, and found that this is caused by the application pool on the webserver recycling from time to time, and hereby generating a new machine key for the application.

The solution: Generate a static machine key and put it in your web.config.
I found the answer here: http://forums.asp.net/p/947381/1147268.aspx.

See this resource for creating a machine key: http://aspnetresources.com/tools/keycreator.aspx.


Another problem bites the dust!


UPDATE: Well it doesn't seem to be that simple after all. The login still isn't persisten :-(