FormsAuthentication.Authenticate authenticates but doesn't redirect
Posted on 2011-02-12
I have an asp.net application in whose pages are free to view to every one however in it I have added a folder called "Demo" that needs protection and a login page.
In my web.config i have:
<authentication mode="Forms" >
<forms loginUrl="Admin.aspx" defaultUrl="DemoFolder/Demo.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" >
<user name="joe" password="test" />
In the location section I have:
And in my login_click() event I have:
if (FormsAuthentication.Authenticate(txtUserName.Text, txtPassword.Text))
Msg.Text = "Login failed. Please check your user name and password and try again.";
The Authenticate method definitely works because if I put the wrong passowrkd the Msg.Text will be executed. I have very similar code elsewhere and it works.
Any ideas welcome.