我遇到了结束会话的问题。当我单击“WebForms.asax”中的按钮时,会话计数时间从零到一分钟(如果我单击此按钮会话将永远不会结束)。我给了 1 分钟的时间来结束所有会话,当我不点击网站时它就可以工作。你知道问题出在哪里吗?
我在这里开始会议:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Session_Test
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["UserAuthentication"] = "dddd";
TypSession.InnerHtml = "<a href='WebForm1.aspx'>sdsds</a>";
}
}
}
另一个网站(WebForm1.aspx):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Session_Test
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
example.InnerHtml = Session["UserAuthentication"].ToString()+" "+ Session.Timeout.ToString();;
}
protected void Unnamed1_Click(object sender, EventArgs e)
{
Response.Redirect(Request.RawUrl);
Session.Abandon();
}
}
}
全球.asax
void Session_Start(object sender, EventArgs e)
{
Session.Timeout = 1;
}
void Session_End(object sender, EventArgs e)
{
Response.Redirect("http://localhost:51888/Default.aspx");
}