如何在 WebForms 的自定义错误页面中显示异常消息?
我在 webforms 中编写了一段代码,用于重定向到 web.config
文件中的自定义错误页面。
<customErrors mode="On" defaultRedirect="~/ErrorPages/Oops.aspx">
<error statusCode="500" redirect="~/ErrorPages/StatusCode500.aspx" />
</customErrors>
我写了一个代码,它给了我数据库错误。
和 StatusCode500 的代码是:
<div class="d-flex justify-content-center">
<h1 style="color: #00AEC0">Oops..Could not connect to Database. </h1>
</div>
<div class="d-flex justify-content-center">
<h4 style="color: #00AEC0">Please contact your Network Administrator</h4>
</div>
它工作得很好,但现在我需要的是我需要将异常消息(在本例中除以零错误)传递到下面的 StatusCode500 页面请请与您的网络管理员联系。我如何传递异常消息或错误 ID?
I have written a code in webforms to redirect to the custom error page in web.config
file.
<customErrors mode="On" defaultRedirect="~/ErrorPages/Oops.aspx">
<error statusCode="500" redirect="~/ErrorPages/StatusCode500.aspx" />
</customErrors>
And I have written a code which gives me database error.
and the code for StatusCode500 is:
<div class="d-flex justify-content-center">
<h1 style="color: #00AEC0">Oops..Could not connect to Database. </h1>
</div>
<div class="d-flex justify-content-center">
<h4 style="color: #00AEC0">Please contact your Network Administrator</h4>
</div>
It works absolutely fine, but now what I need is I need to pass the exceptional message (Divided by zero error in this case) to the StatusCode500 page just below Please contact you network administrator . How can I pass that exceptional message or Error Id?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论