C# asax文件中的响应在此上下文中不可用

C# asax文件中的响应在此上下文中不可用,c#,C#,我有一个只适用于Firefox的登录页面。它不适用于任何其他浏览器 当我检查事件日志时,我看到“响应在当前上下文中不可用”。它告诉我错误在global.asax文件的response.redirect行: void Session_End(object sender, EventArgs e) { Response.Redirect("~/Login.aspx?li=1"); // Code that runs when a session ends. // Not

我有一个只适用于Firefox的登录页面。它不适用于任何其他浏览器

当我检查事件日志时,我看到“响应在当前上下文中不可用”。它告诉我错误在global.asax文件的response.redirect行:

void Session_End(object sender, EventArgs e) 
{
     Response.Redirect("~/Login.aspx?li=1");
    // Code that runs when a session ends. 
    // Note: The Session_End event is raised only when the sessionstate mode
    // is set to InProc in the Web.config file. If session mode is set to StateServer 
    // or SQLServer, the event is not raised.

}
有什么问题吗

我尝试了httpcontext.Current,正如建议的那样,但是我得到了一个空引用异常,对象引用未设置为对象的实例


谢谢。

尝试使用
HttpContext.Current.Response
它肯定会工作。

您尝试过使用HttpContext.Current.Response吗


快乐编码

我尝试过这个,但这是抛出NullReferenceException,我是stuckIt没有。HttpContext.Current.Response在会话_End内为null。