Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Exceptions to an error screen in ASP.net/C#

Coming from a desktop background I'm not sure exactly how to pass the exceptions I have caught to an Error page in order to avoid the standard exception screen being seen by my users.

My general question is how do I pass the exception from page X to my Error page in ASP.net?

like image 748
Collin Estes Avatar asked Dec 10 '22 23:12

Collin Estes


1 Answers

I suggest using the customErrors section in the web.config:

   <customErrors mode="RemoteOnly" defaultRedirect="/error.html">
      <error statusCode="403" redirect="/accessdenied.html" />
      <error statusCode="404" redirect="/pagenotfound.html" />
   </customErrors>

And then using ELMAH to email and/or log the error.

like image 195
Forgotten Semicolon Avatar answered Dec 26 '22 23:12

Forgotten Semicolon