简体   繁体   English

ASP.NET:如何将数据传递到自定义错误页面

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

如何使用Server.Transfer或某些重定向将某些数据从Global.asax事件处理程序传递到ASP.NET中的自定义错误页面?

Assuming you're catching unhandled exceptions in global.asax, I don't think you can. 假设您在global.asax中捕获了未处理的异常,我认为您不能。 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. 您可以尝试通过为Page_Error事件添加处理程序来捕获每个页面中未处理的异常。 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. 您可以通过让每个页面子类成为您自己的应用程序“页面基础”类而不是System.Web.UI.Page来集中其中的某些内容,并确保“页面基础”类继承自System.Web.UI.Page。 Then have your page base class handle Page_Error. 然后让您的页面基类处理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. 但是那时候您将不会使用特定于页面的代码,因此您仍然必须找出一种将数据传递到该自定义错误页面的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决ASP.NET自定义登录页面错误? - How to solve ASP.NET custom login page error? asp.net中的自定义错误页面 - custom error page in asp.net 如何使用ASP.NET MVC 3将“昂贵”的数据从页面传递到页面? - How do you pass “expensive” data from page to page using ASP.NET MVC 3? 将数据从数据库传递到ASP.NET页 - Pass data from database to ASP.NET page (动态数据,ASP.Net,C#,下拉列表自定义.ascx控件)如何在下拉列表之间传递值? - (Dynamic Data, ASP.Net, C#, dropdownlists custom .ascx controls ) HOW TO PASS VALUES AMONG DROPDOWNLISTS? ASP.NET MVC-如何在C#中构建自定义视图模型以将数据集传递给强类型视图? - ASP.NET MVC - How to build custom viewmodels in C# to pass a data set to a strongly typed View? 如何将数组数据从asp.net页传递到javascript代码? - how to pass array data to the javascript code from asp.net page? 如何在ASP.NET C#中将数据从页面传递到用户控件,反之亦然? - How to pass data from page to user control and vise versa in asp.net C#? ASP.NET MVC 2中的自定义403错误页面 - Custom 403 error page in ASP.NET MVC 2 ASP.NET MVC 应用程序的自定义 401 错误页面 - Custom 401 error page for ASP.NET MVC application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM