这个问题似乎与这篇文章有关,但我无法从线程中推断出解决方案。
我在我继承的应用程序中注意到了这段代码(在日志文件中注意到异常被吃掉之后):
protected void Session_End(object sender, EventArgs e)
{
try
{
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
//if (this.Context.Handler is IRequiresSessionState || this.Context.Handler is IReadOnlySessionState)
//{
// FormsAuthentication.SignOut();
// FormsAuthentication.RedirectToLoginPage();
//}
}
catch (Exception ex)
{
this.GetType().GetLogger().Error(ex);
}
}
我想知道几件事。首先,SignOut 是如何抛出空引用异常的?这是一个例外情况,还是我在我的程序中做错了什么?接下来,我应该测试什么来阻止这个异常被抛出?
15:51:57,288 [13] 错误 ASP.global_asax - System.NullReferenceException:对象引用未设置为对象的实例。在 System.Web.Security.FormsAuthentication.SignOut() 在 MvcApplication.Session_End
谢谢