ASP.NET Membership Problem

Hi all,
I have an issue with a website I am maintaining. Users have reported that they sign into the website, but as soon as they redirect to another page or when they just do a postback, they get directed to the login page.

I was able to recreate this issue once. I hit the refresh button and from that point on it started working fine again. I also had another user state the setting the “remember me” option to yes fixed their problem.

Has anyone had similar issues to this with membership? I will post my code later, but was hoping to get feedback as soon as possible.

The solution is very simple. First you need to understand what is causing this. When you log in, an authentication cookie is created. This authentication cookie is encrypted using the machinekey in your web.config. But if you didn’t specify a machine key, ASP.NET will generate one. But when the application recycles, a new machine key is generated. The authentication ticket, holding the credentials was encrypted using a different key and cannot be decrypted anymore, so you’re redirected to the login page.

So what you should do is create a machine key in your web.config, and this problem should be solved.

It is a shared hosting account, so there isn’t a way for me to check the application pool.

First port of call would be to make sure your application pool isn’t recycling too often.