Page not loading correctly after login

Chris Ara
01-09-2007, 07:16 AM
I'm having trouble with my log in page code. Once you successfuly log in from the log in page you are redirected to a home page. The home page and all the other pages work properly until you log in. Once you transfer after the log in it will load two copies of the home page at the same time ???? Then all the buttons and links on the home page won't work , if you redirect then come back to sight after you have logged in (without closing the window) the buttons and links will work once again and there will only be one copie of the page loaded into your browser. Here is the code for the login page tell me if you see anything that would cause this.

Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs)

Try

Dim Reader As New IO.StreamReader(Server.MapPath("." & "/profiles/" & LoginUser.UserName.ToLower & ".txt"))

Dim Age As String = Reader.ReadLine
Dim Sex As String = Reader.ReadLine
Dim Location As String = Reader.ReadLine
Dim Hobbies As String = Reader.ReadLine
Dim Quote As String = Reader.ReadLine
Dim Picture As String = Reader.ReadLine
Dim PassWord As String = Reader.ReadLine

Reader.Close()

If LoginUser.Password.ToLower = PassWord.ToLower Then

Session("User") = LoginUser.UserName.ToLower
Session("PassWord") = LoginUser.Password.ToLower
Session("Profile") = "None"

Server.Transfer("Home.aspx")

End If

Catch ex As Exception

Server.Transfer("LogIn.aspx")

End Try

End Sub

As you can see basically I am loading a profile from a text file then checking the password in the file against the password in the password box if the passwords match then you are redirected to the home page.

thanks for any help
Chris Ara

wayneph
01-09-2007, 12:21 PM
It looks like you're trying to reinvent the wheel. .NET has FormsAuthentication classes built in that should be able to help with this. You shouldn't have to manage it yourself in Session variables like you did in Classic ASP.

Take a look at the System.Web.Security.FormsAuthentication Class. You should be able to use the RedirectFromLoginPage() Method to send you back to your Home page. It will also manage the cookies for the session, or save it longer so that it is remembered for the next visit.

Chris Ara
01-09-2007, 01:02 PM
LOL ok I have all the microsoft certifications books one of the books talks about verification using windows , passport and so on. The only problem is windows verification works only from a local network and passport well I don't feel like paying them to use there services lol. I will just stick to the classical way. Auctually it is the try statement causing the page to load twice. Why I don't know but once I got rid of this statement the page was loading correctly. Thanks for the suggestion though.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum