Wednesday, March 08, 2006

ASP.NET Forms Authentication - Problem Solved

ASP.NET is not my forte. Having disclosed that, I'm currently working on a ASP.NET application that takes advantage of the Membership Provider in ASP.NET 2.0 and uses Forms Authentication.

This application worked great from the development web server (you know, that Cassini web server that comes with Visual Studio 2005). But, when I tried to deploy this to a real IIS6 web server, I ran into problems.

When I hit the site, the web server would correctly redirect my browser to the login page. However, upon logging in, my browser would keep getting sent back to the login page (with no error message, like "Bad User name or Password").

I was just about ready to throw my server across the room, and was even drafting a "please help" letter to Josh, when I decided to take another look at my web.config.

And that's when I saw it:

<authentication mode="Forms">
<forms name="AppNameCookie"
cookieless="UseCookies" />

You see, in my Visual Studio solution, the web project was simply named "web". But, I was trying to deploy it to a more meaningful virtual directory name (i.e., "myapp").

So, I changed the above "/web" to "/myapp", and it started working. I hope that this saves someone the hours of frustration that I experienced today.