|
-
Jun 1st, 2007, 03:53 PM
#1
Thread Starter
Fanatic Member
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
-
Jun 1st, 2007, 04:21 PM
#2
Thread Starter
Fanatic Member
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
-
Jun 2nd, 2007, 09:48 AM
#3
Hyperactive Member
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
-
Jun 4th, 2007, 09:11 AM
#4
Thread Starter
Fanatic Member
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
-
Jun 4th, 2007, 10:20 AM
#5
Hyperactive Member
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.
-
Jun 4th, 2007, 10:27 AM
#6
Thread Starter
Fanatic Member
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
-
Jun 4th, 2007, 01:39 PM
#7
Hyperactive Member
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">
-
Jun 4th, 2007, 01:44 PM
#8
Hyperactive Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|