Hi.
I have just been working through the ASP.Net 2.0 training video (Bob tabor : number 09 - Securing your Website with Membership and Login Controls) and have come across a problem.
In the demo, towards the end, it shows you how to check that a user is a member of a Role. The code used is: -
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If User.Identity.IsAuthenticated = False Then
Server.Transfer("login.aspx")
End If
If Roles.IsUserInRole("Basic User") = False Then
Server.Transfer("unauthorized.aspx")
End If
End Sub
In the demo, the trainer goes to the page called SecurePage.aspx and enters a username that is valid but that he knows is NOT a member of the Role "Basic User". He is then redirected as per the code above to unauthorized.aspx.
On the unauthorized.aspx form, there is a LoginStatus control. When he is testing the demo, he clicks the LoginStatus control - which is currently on "Logout". The page is refreshed and the Logout is replaced with a "Login".
He then enters a username that he know IS a member of the "Basic User" Role. This time when he click Log in, he gets redirected to the Secure page - which is correct.
However, when I attempt that last step, I get sent back to the unauthorized page.
I've checked the obvious things - like that the user was actually in the Role etc.
However, I just cannot get this to work.
I am new to ASP.Net and so I don't really know where to start to look for what the problem is?
Could it be some setting or something on my machine causing this problem?
For info, I am using: -
- Visual Studio .Net 2005 (Professional) (up to date)
- Latest .Net installed
- Windows XP Pro
- Internet Explorer 6 (version 6.0.2900.2180.xpsp_sp2_gdr.050301-1519) SP2
Obviously, if it works in the video, it should work on my PC. It does not and I really need to know why and what the problem is.
Any help appreciated.
Kind regards
Darren Brook