views:

278

answers:

2

I'm starting to use Role Management in my website, and I'm current following along on the tutorial from http://www.asp.net/Learn/Security/tutorial-02-vb.aspx .

I'm having a problem with the asp:LoginStatus control. It is not telling me that I am currently logged in after a successful login. This can't be true because after successfully logging in, my LoggedInTemplate is shown. The username and passwords are simply stored in a array. Heres the Login.aspx page code.

Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles btnLogin.Click ' Three valid username/password pairs: Scott/password, Jisun/password, and Sam/password.

    Dim users() As String = {"Scott", "Jisun", "Sam"}

    Dim passwords() As String = {"password", "password", "password"}

    For i As Integer = 0 To users.Length - 1

        Dim validUsername As Boolean = (String.Compare(txtUserName.Text, users(i), True) = 0)

        Dim validPassword As Boolean = (String.Compare(txtPassword.Text, passwords(i), False) = 0)

        If validUsername AndAlso validPassword Then

            FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, chkRemember.Checked)

        End If

    Next

    ' If we reach here, the user's credentials were invalid

    lblInvalid.Visible = True
End Sub

Here is the content place holder on the master page specifically designed to hold Login Information. On successfull login, the page is redirected to '/Default.aspx', and the LoggedIn Template below is shown...but the status says Log In.

<asp:ContentPlaceHolder Id="LoginContent" runat="server">
     <asp:LoginView ID="LoginView1" runat="server">

           <LoggedInTemplate>

                Welcome back, <asp:LoginName ID="LoginName1" runat="server" />.

           </LoggedInTemplate>

           <AnonymousTemplate>

                Hello, stranger. 

           </AnonymousTemplate>

      </asp:LoginView>

      <br />
        <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Logout.aspx" />

      </asp:ContentPlaceHolder>

Forms authentication is enabled. I'm not sure what to do about this :o.

A: 

I don't see anything wrong with your code, and the tutorial code works for me. Have you tried using the downloadable code for the tutorial to see if it exhibits the same behaviour?

Sample Tutorial Code

Jason Berkan
I'll try it, thanks.
contactmatt
Nothings been working. Any suggestions anyone?
contactmatt
A: 

Fixed: I had asp.net configuration settings, that had existing users/roles. So every time I would try to log on, it wouldn't work. To fix this, reset the asp.net configuration settings, or start the new project from scratch (which I didn't do)

contactmatt