QFDev
QFDev

Reputation: 9008

.NET Compilation Error, show user friendly screen

I've configured the web.config to show user friendly 404 and 500 errors using the following declaration:

<customErrors mode="Off" redirectMode="ResponseRewrite">
  <error statusCode="500" redirect="error.aspx"/>
  <error statusCode="404" redirect="404.aspx"/>
</customErrors>

However occasionally when we're FTP'ing classes up to the server (in the App_Code folder) we may cause a compilation error that doesn't get handled gracefully and the user sees the yellow screen of death. Is there a way to hide this and show a standard holding page instead? Perhaps some adaptation of the web.config declaration above?

I know ideally we should be compiling first and publishing but we are doing a lot of dynamic changes at the moment, that make this difficult.

Upvotes: 1

Views: 539

Answers (1)

Evaldas Dzimanavicius
Evaldas Dzimanavicius

Reputation: 645

You can modify web.config in following way to show user-friendly messages on any error:

<customErrors mode="on" defaultRedirect="otherError.aspx" redirectMode="ResponseRewrite">
  <error statusCode="500" redirect="error.aspx"/>
  <error statusCode="404" redirect="404.aspx"/>
</customErrors>

Edit:

If you don't want to see compilation errors while updating your website, you can take it offline for the time of the update. To do that, put a file named app_offline.htm in the root of your website. The content of that file should state, that website is under maintenance/update. You can adapt content that it will be in the same style as your website. When you are done with the updates, simply rename that file and website will work as supposed to.

Upvotes: 1

Related Questions