views:

547

answers:

3

I have configured my web.config to show 'error.htm' error page when exceptions occur on the website. But I am unable to show the page when an asp.net compilation error occurs. How do I make that happen. Im running on IIS 7.

A: 
<customErrors mode="RemoteOnly" />

The mode attribute can be one of the following:

  • On – error details are not shown to anybody, even local users. If you specified a custom error page it will be always used.
  • Off – everyone will see error details, both local and remote users. If you specified a custom error page it will NOT be used.
  • RemoteOnly – local users will see detailed error pages with a stack trace and compilation details, while remote users with be presented with a concise page notifying them that an error occurred. If a custom error page is available, it will be shown to the remote users only.
adatapost
This does not work. A yellow screen is still shown and now the Error.htm. Instead of getting a Compile Error message you now just get a Runtime Error message telling you to change the customErrors.
Sailing Judo
A: 

set the mode attribute to On so error details will not shown to anybody.

<customErrors
       mode="on" 
       defaultRedirect="~/errorpage.aspx" 
/>
Wael Dalloul
This does not work. A yellow screen is still shown and now the Error.htm. Instead of getting a Compile Error message you now just get a Runtime Error message telling you to change the customErrors.
Sailing Judo
+1  A: 

Why would you have a compilation error on a live site?

But, without testing, I can't imagine what you are trying to do is possible. If it can't compile it can't run any code.

Clarence Klopfstein
In our case somebody forgot to include a third-party assembly which ended up causing a compile error so it *can* happen. :)
Sailing Judo
Then I think what I said still stands, if you can't run code.. you can't show a friendly error as it is just dead in the water. If it is possible to do otherwise, that would be a nice find.
Clarence Klopfstein