修改密码网页的load代码如下:
if(Session["userName"]==null)
{
Response.Write("已经超时!");Response.End();
}
pswModify1.tableName = "管理员";
pswModify1.userName = Session["userName"].ToString();
Session.Remove("userName");
判断session不为空,出现了脚本错误,如下图:
登陆界面相关代码如下:(不知道session定义变量的位置对不对)
case "管理员":
{
string strSelect = "select count(*)from 管理员 where 用户名='" + strUserName + "'and 密码='" + strPassword + "'";
System.Data.SqlClient.SqlCommand selectCom = new System.Data.SqlClient.SqlCommand(strSelect, conn);
int count = int.Parse(selectCom.ExecuteScalar().ToString());
conn.Close();
if (count > 0)
{
Session["userName"] = txtUserName.Text;
Response.Redirect("welcomemanager.aspx");
}
else
{
Label1.Text = "用户名或密码输入错误!";
}
}
不知道问题出现在那里,有劳解答,谢谢你。
Session这种会过期为空的对象要先判断是否为空才能引用
if(Session["userName"]==null)
{
Response.Write("已经超时!");Response.End();
}
pswModify1.tableName = "管理员";
pswModify1.userName = Session["userName"].ToString();
Session.Remove("userName");
关于session_end的执行测试,解决困惑 很惭愧这个问题困惑了我2天时间, 查阅无数文章,最后经过测试发现,这些文章并没有说到重点
包括csdn里很多程序员也没有搞清楚怎么回事,其实seesion_end方法不执行的原因很简单.
有三点吧,第一是config.sys设置问题,在system.web节点下添加
<sessionState mode="InProc&quo......
答案就在这里:ASP.NET中Session的问题
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。