开发者

ASP.NET: How to pass data to a custom error page

How can I pass some data from a Global开发者_运维知识库.asax event handler to a custom error page in ASP.NET without using Server.Transfer or some redirect?


Assuming you're catching unhandled exceptions in global.asax, I don't think you can. You're no longer in anyone's session at that point, so you've lost just about all connection with the error, other than the exception itself.

You might try catching unhandled exceptions in each page, by adding a handler for the Page_Error event. You can centralize some of that by having each page subclass your own application "page base" class instead of System.Web.UI.Page, and make sure that your "page base" class inherits from System.Web.UI.Page. Then have your page base class handle Page_Error. But you won't be in page-specific code at that point, so you'll still have to figure out a method for passing data to that custom error page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜