ravl
asked on
RedirectFromLoginPage refuses to work!
Windows XP Prof.
FormsAuthentication.Redire ctFromLogi nPage(txtU serID.Text , True) fails to redirect to original URL.
I have text book code as described in the MS MCAD/MCSD self paced training book. I know it works 'cos I've had it working. But now it refuses to work! Can't believe the time I've spent trying to track this down. Now it's driving me crazy! Pls can anyone see a problem?
Redirection to the login page happens OK. The user is validated OK and the cookie gets written OK but the application just stays on the login page.
root webconfig:
<authentication mode="Forms">
<forms name="freddy" loginUrl="AdminLogin.aspx" >
<credentials passwordFormat="SHA1">
</credentials>
</forms>
</authentication>
restricted folder webconfig:
<authorization>
<deny users="*" />
</authorization>
AdminLogin.aspx:
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
'authenticate username/password from Users.xml
If IsUserValid(txtUserID.Text , txtPassword.Text) Then
FormsAuthentication.Redire ctFromLogi nPage(txtU serID.Text , True)
Else
litStatus.Text = "This userID and password is not authorised, try again."
End If
End If
End Sub
FormsAuthentication.Redire
I have text book code as described in the MS MCAD/MCSD self paced training book. I know it works 'cos I've had it working. But now it refuses to work! Can't believe the time I've spent trying to track this down. Now it's driving me crazy! Pls can anyone see a problem?
Redirection to the login page happens OK. The user is validated OK and the cookie gets written OK but the application just stays on the login page.
root webconfig:
<authentication mode="Forms">
<forms name="freddy" loginUrl="AdminLogin.aspx"
<credentials passwordFormat="SHA1">
</credentials>
</forms>
</authentication>
restricted folder webconfig:
<authorization>
<deny users="*" />
</authorization>
AdminLogin.aspx:
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
'authenticate username/password from Users.xml
If IsUserValid(txtUserID.Text
FormsAuthentication.Redire
Else
litStatus.Text = "This userID and password is not authorised, try again."
End If
End If
End Sub
ASKER
Thanks Aeros. But the Response.Redirect makes no difference, still stuck on the login page. This also ties you to redirection to a specific page.
did you set your web.config for forms authentication?
ASKER
Yes - as I described the root web.config has <authentication mode="Forms">
but did you specify the loginUrl so it knows where to return?
<authentication mode="Forms" >
<forms name="synthesis" loginUrl="login.aspx" timeout="30" />
</authentication>
<authentication mode="Forms" >
<forms name="synthesis" loginUrl="login.aspx" timeout="30" />
</authentication>
ASKER
AerosSaga - if you read the detail I provided you will see that I have indeed done this.
ASKER
The trick, always obvious once someone points it out, dear friends is:
<deny users="?" /> to deny unauthenticated users in the restricted web folder's webconfig.
Eventually found an answer in one of the many web forums through someone who had the same problem.
Sorry I can't allocate any points in this case. But thanks anyway.
<deny users="?" /> to deny unauthenticated users in the restricted web folder's webconfig.
Eventually found an answer in one of the many web forums through someone who had the same problem.
Sorry I can't allocate any points in this case. But thanks anyway.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
'authenticate username/password from Users.xml
If IsUserValid(txtUserID.Text
FormsAuthentication.Redire
Response.Redirect("Mypage.
Else
litStatus.Text = "This userID and password is not authorised, try again."
End If
End If
End Sub
Regards,
Aeros