British Inside

An Englishman living in small town America

James Shaw

News

  • Copyright James Shaw 2004-2007

    Creative Commons License

    View James Shaw's profile on LinkedIn

New app losing your signin?

At the weekend I had a problem with a new site where it would keep asking me to sign in every time I visited. It's well known now that ASP.NET 2.0 changed the way that timeouts worked, so I checked the web.config to make sure a long timeout was specified for the forms authentication. Check.

But, still, after a very short period of time when I returned to the site I'd be Mr. Anonymous again. Tongue Tied

I also noticed that sometimes I'd see an error: Unable to validate data

It took a few minutes to google up some suggestions (it seems a long while since this particular problem was an issue for me) - but Jeremy hit the nail on the head. And now that I know what the problem is, I'm not sure I did come across this version before..

In a nutshell; this new site was just being visited occasionally by me - and IIS on that server was setup to stop the app pool after 30 minutes of idle time. And the default behavior is to generate a new machineKey whenever the app starts - which invalidates the auth ticket.

A quick fix - put a static machineKey into your web.config. Don't forget to make it a randomly generated one though, eh? Wink


Posted: Monday, June 04, 2007 2:21 PM by James

Comments

Scott Cate said:

James, I built a page to generate these randomly. Saves people from having to download / install / compile anything. Just grab a random sha1 from the page.

http://www.scottcate.com/Gen128.aspx
# June 15, 2007 3:54 PM
New Comments to this post are disabled