开发者

Display specific error message on custom error page

开发者 https://www.devze.com 2023-04-01 00:51 出处:网络
I know it\'s possible in asp.net to create a custom error page in a web app, by putting the following line in the web.config:

I know it's possible in asp.net to create a custom error page in a web app, by putting the following line in the web.config:

<customErrors mode="RemoteOnly" defaultRedirect="frmErrorPage.aspx" />

I have had to do this for my web app, since it is clearly much tidier than letting the program bomb out with it's ugly default error page. My custom error page just has the customer's logo and a brief messag开发者_运维知识库e saying "Error has occurred. Please return to homepage"

The trouble now is that I have no way of knowing what caused the error, when a customer reports it.

Is there a way to make the actual error message appear on this custom error page too?


You should be using logging to know when/where/what errors occured. The POINT of the custom error page is to not allow the end user to see why it messed up because obviously that could be a security risk. Look into using ELMAH. It automatically creates a nice web gui for any uncaught exceptions. And you can also create logs when you catch the errors yourself. If you do chose to use ELMAH, I would also strongly recommend installing it with the NuGet package manager

0

精彩评论

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