大家好, 我创建了一个使用asp语言作为vb的网站。 登录后我有一个login.aspx页面,它重定向到welcome.aspx。 首次登录时,编译器会转到page_load并创建一个会话。 br /> 当我点击提交按钮时,我将在submit_click事件中验证我创建的会话。现在,在单击提交按钮时会话被清除。因此它不允许我登录并再次将我重定向到登录页面。 再次给出相同的凭证并单击提交按钮,这次它具有会话值,它允许我welcome.aspx页面。 很明显,会话在第一次回发时被清除。第二次它有价值。 请在下面找到我的代码。
Hi All, I have created a website using asp 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.
'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请帮我解决这个问题。 问候, Norbert
Kindly please help me to solve this. Regards, Norbert
推荐答案尝试删除If Not IsPostBack语句并分配它.. try with removing If Not IsPostBack statement and assign it anyway..
更多推荐
会话第一次自动清除,第二次运行正常
发布评论