Results 1 to 8 of 8

Thread: ASP.NET 2.0 Authenticating not working

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    ASP.NET 2.0 Authenticating not working

    Hello all,

    I'm doing some testing with implementing my own login using the membership class. To make it simple, I used the ASP.NET 2.0 config tool and created 1 user. I then threw two text boxes (for usernam and password) and a button (to login) on my webform.

    I should be able to authenticate by using this in the button's click event:
    Code:
    'Login user
                    If Membership.ValidateUser(txtUserName.text, "txtPassword.text") Then
                        FormsAuthentication.SetAuthCookie(userName, False)
                        
                    Else
                        'Not Authenticated
                    End If
    I don't understand why its not working. Does anyone know if I'm doing something wrong? I'm usnig ASP.NET 2.0 and VB 2005

    Thanks,

    Strick

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Re: ASP.NET 2.0 Authenticating not working

    Ok, I'm a little closer, but this is weird. Ok if I login, the authentication isn't working right? After attempting to login again (2nd time), it works. I then stopped the application and tried it again and got the same result. It will login on the second attempt. Not sure if this has something to do with postback or not. Has anyone ever experienced this?

    Strick

  3. #3
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    354

    Re: ASP.NET 2.0 Authenticating not working

    http://samples.gotdotnet.com/quickst...celogpage.aspx
    put a Trace="true" then drop some Trace.Write(txtUserName.text)

    If you are using IIS 6, open up the admin console right click on your virtual server and change your authenication to windows form authentication. I think it defaults to nt creditals if I remember right.

    the webconfig way:
    http://msdn2.microsoft.com/en-us/lib...47(VS.71).aspx

    http://www.ondotnet.com/pub/a/dotnet...rmsauthp1.html

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Re: ASP.NET 2.0 Authenticating not working

    Hmmm... I stand corrected. Looks like what I'm doing is actually authenticating correctly. The problem is the built-in LoginName control (I was using this to validate whether the user was logged in) doesn't flip to show the log in name until the page is refreshed (after I hit F5). The user is logged in after my code snippet first runs (I validated this with the User.Identity.IsAuthenticated) so I'm not sure why the built-in LoginName control doesn't flip until the page is refreshed again (F5).

    Also, FYI, I tried the login status control as well and got the same result. User is authenticated, but the contorl doesn't flip until the page is refreshed.

    Anyone know why this is happening?

    Thanks,

    Strick

  5. #5
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Re: ASP.NET 2.0 Authenticating not working

    I feel your pain... I am having issues with this new authentication stuff... I am sure you tried to do a postback after the login, that will refresh the page.
    TMacPherson
    MIS Systems Engineer
    [email protected]


  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Re: ASP.NET 2.0 Authenticating not working

    Yes. It authenticates, but doesn't refresh the LoginName (or LoginStatus) control until I refresh the page. I guess I'm just going to go with what I have since I havn't found an answer. But my users are authenticating though. I'm just not going to use the loginName (and LoginStatus) controls on the same page that I'm logging in from. If I place them on a different page in my application, this works fine since there is a page refresh to get to that page.

    Strick

  7. #7
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Re: ASP.NET 2.0 Authenticating not working

    How about doing a Meta refresh on that page? just an idea.
    Code:
    <meta http-equiv="refresh" content="0">
    TMacPherson
    MIS Systems Engineer
    [email protected]


  8. #8
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Re: ASP.NET 2.0 Authenticating not working

    Never mind that would not work because you would want to stay on that page, and of course you don't want it to refresh constantly.
    TMacPherson
    MIS Systems Engineer
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width