您的位置:首页 > 其它

这真是一个奇怪的问题。

2005-06-02 14:53 281 查看
http://files.cnblogs.com/cookieswolf/errortest.rar

这真是一个奇怪的问题。

启动页面webform1.aspx
private void Button1_Click(object sender, System.EventArgs e)
{
string w=Application["dsf"].ToString();
}
Application["dsf"]是没有的我故意来引发错误。

Global.asax

protected void Application_Error(Object sender, EventArgs e)
{
HttpApplication application = ( HttpApplication )sender;

HttpContext context = application.Context;
Exception exceptions;
if ( context.Server.GetLastError().GetBaseException() is Exception )
{
exceptions = ( Exception ) context.Server.GetLastError().GetBaseException();
Session["hehe"]="ERROR: " + exceptions.Message + "\r\n" + exceptions.InnerException;
Response.Redirect(HttpContext.Current.Request.ApplicationPath+"/webform2.aspx");
}
else
{
exceptions = new Exception("Unknow Error", context.Server.GetLastError());
throw exceptions;
}

}
Session["hehe"]是用来存储错误信息,用来在weform2中显示。
webform2.aspx:
Label1.Text=(string)Session["hehe"];

但是很奇怪Session["hehe"]是空的不存在。

这种情况只是在Application,Session引发的错误存在。虽然用别的方法解决了。但是非常不理解。请大家帮忙看一下。谢谢。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: