As is suggested elsewhere, I am using redirectMode = ResponseRewrite in my custom error configuration so my custom error page can access the exception info. This has worked like a charm for some time.
正如其他地方所建议的那样,我在自定义错误配置中使用redirectMode = ResponseRewrite,因此我的自定义错误页面可以访问异常信息。这有点像魅力一段时间了。
In adding some more "help the user recover from an error" type functionality, we need a piece of info that has been previously stored in Session. When implementing this, I found that the various avenues to Session end in null when redirectMode=ResponseRewrite, but they are all populated when redirectMode=ResponseRedirect (or isn't defined).
在添加更多“帮助用户从错误中恢复”类型功能时,我们需要一段先前存储在Session中的信息。实现这一点时,我发现当redirectMode = ResponseRewrite时,Session的各种途径以null结尾,但是当redirectMode = ResponseRedirect(或未定义)时,它们都被填充。
Anyone know why? It seems odd that we'd have to choose between having exception info (ResponseRewrite) or having Session (ResponseRedirect).
谁知道为什么?我们必须在具有异常信息(ResponseRewrite)或具有Session(ResponseRedirect)之间进行选择,这似乎很奇怪。
The MSDN article on Rich Custom Error handling tells me that Session is only available when the control passing method is Server.Transfer, which is what I assumed ResponseRewrite used under the hood. Evidently that isn't the case.
关于Rich Custom Error处理的MSDN文章告诉我,Session只有在控制传递方法是Server.Transfer时才可用,这是我假设在引擎盖下使用的ResponseRewrite。显然事实并非如此。
1 个解决方案
#1
5
I don't know the answer to the question yet, but to get past it, I took the redirectMode attribute out of my web config and put custom logic in the Global.asax Application_Error
handler to do what I wanted. I am replacing the exception with a "user friendly" message exception, but essentially the transfer logic is:
我还不知道这个问题的答案,但是为了解决这个问题,我从我的web配置中取出了redirectMode属性,并将自定义逻辑放在Global.asax Application_Error处理程序中以完成我想要的操作。我用“用户友好”消息异常替换异常,但基本上转移逻辑是:
if(Context.IsCustomErrorEnabled)
{
Server.Transfer("~/Error.aspx");
}
if(Context.IsCustomErrorEnabled){Server.Transfer(“〜/ Error.aspx”); }
Then the Error.aspx page has Page_Load code to pull the error out of context and display the message.
然后Error.aspx页面有Page_Load代码将错误拉出上下文并显示消息。
#1
5
I don't know the answer to the question yet, but to get past it, I took the redirectMode attribute out of my web config and put custom logic in the Global.asax Application_Error
handler to do what I wanted. I am replacing the exception with a "user friendly" message exception, but essentially the transfer logic is:
我还不知道这个问题的答案,但是为了解决这个问题,我从我的web配置中取出了redirectMode属性,并将自定义逻辑放在Global.asax Application_Error处理程序中以完成我想要的操作。我用“用户友好”消息异常替换异常,但基本上转移逻辑是:
if(Context.IsCustomErrorEnabled)
{
Server.Transfer("~/Error.aspx");
}
if(Context.IsCustomErrorEnabled){Server.Transfer(“〜/ Error.aspx”); }
Then the Error.aspx page has Page_Load code to pull the error out of context and display the message.
然后Error.aspx页面有Page_Load代码将错误拉出上下文并显示消息。