会话第一次自动清除,第二次运行正常

编程入门 行业动态 更新时间:2024-10-11 11:14:20
本文介绍了会话第一次自动清除,第二次运行正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我创建了一个使用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..

更多推荐

会话第一次自动清除,第二次运行正常

本文发布于:2023-11-23 04:25:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620081.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!