Click here to Skip to main content
15,886,046 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have created a website using asp.net language as vb.

I have a login.aspx page after login it redirects to welcome.aspx.

While first time login, the compiler goes for page_load and it creates a session.

While am clicking submit button, i will verify the session created by me in submit_click event. now, while clicking the submit button the session is cleared. so it does not allow me to login and redirects me again to login page.

Again am giving the same credential and clicked submit button , this time it has the session value, and it allow me to welcome.aspx page.

Clearly, the session was cleared on first time postback. on second time it has the value.

Please find my code below.

VB
'on page_load event
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then
   Session("lid") = "123456"
End if

End Sub

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

If Session("lid") <> Nothing Then
     Response.Redirect("welcome.aspx")
Else
     Response.Redirect("login.aspx")
     Exit Sub
End If

End Sub


Kindly please help me to solve this.

Regards,
Norbert
Posted
Comments
[no name] 6-Sep-14 2:46am    
U assigned session value in Page_Load event. It means when u entering the value is in session so there not chance for null. so where is the problem

1 solution

try with removing If Not IsPostBack statement and assign it anyway..
 
Share this answer
 
Comments
Maria Norbert 11-Sep-14 0:49am    
Hi InnocentAk, Already i tried everything, i dont know why, it is happening...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900