ASP .NET 2.0 forms authentication doesn't work after deployment
I was having trouble with getting my application to authenticate users when I deployed it to my host server. Typical story, everything worked fine when on my local development machine, including using the connection string to the host's sql server. When deployed on the host, the login form would show and when I enter the credentials, the form would pass back to the default page, not displaying any error. It looks as though the user is authenticated, but the LoginView control doesn't change as it does on my local machine. WHen I try and access a restricted part of the web site, I am (appropriately) directed to the login form but every time I enter my credentials it stays on the login form. So, what's going on?
As it turns out, the forms element of the authentication section of the web.config has an attribute called "path" that, if set (along with the cookieless="AutoDetect|UseCookies"), has to relate to the path on the host. Because I was hosting it locally, path="/MySite" worked because of how it was set up on my local machine. It didn't work on the host as I am not certain how they have it set up. I only get to see my own node in the tree. So, the fix was to not include the path attribute, leaving it at the default "/".
Partager