【发布时间】:2018-04-03 02:48:03
【问题描述】:
我使用了 Global.asax,这两个代码在会话超时后给我错误,例如: “在这种情况下没有回应。” - 如果我使用 Response.Redirect '你调用的对象是空的。' - 如果我使用 HttpContext.Current.Response.Redirect
Global.asax
protected void Session_End(object sender, EventArgs e)
{
//HttpContext.Current.Response.Redirect("timeout.aspx");
Response.Redirect("~/timeout.aspx");
}
这是在我的 Web.Config 上
Web.Config
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors defaultRedirect="../error_page/" mode="Off"/>
<sessionState timeout="1" cookieless="false" mode="InProc" ></sessionState>
</system.web>
</configuration>
SessionTimeout.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Session["CustomSessionId"] = Guid.NewGuid();
}
你们有什么解决方案,特别是 sn-ps 的建议来解决这个问题吗?我只是一个入门级程序员,不是高级程序员。
【问题讨论】:
-
检查这个类似的问题:stackoverflow.com/questions/484964/…。还要检查
Session.IsNewSession,因为Session_End事件未附加到任何Request实例。