Webhosting | Hosting - My Hosting PartnerWebhosting | Hosting - My Hosting PartnerWebhosting | Hosting - My Hosting PartnerWebhosting | Hosting - My Hosting Partner

Error messages in ASP.NET

Error messages in ASP.NET
MijnHostingPartner

Error messages in ASP.NET

Error messages in ASP.NET

When you start working and developing with ASP.NET hosting then it is easy to understand the error messages better. ASP.NET and IIS turns some error messages into hard errors. ASP.NET Core hosting has a different method which will be covered in a later article.

It can cause problems when you are looking for that one error. If you leave this further default then the following error messages may appear:

Error messages in ASP.NET

Of course, it can be a bit of a shock when you run into this message. Therefore it is advisable to at least catch the 404 error. This error occurs most often when users for example enter a wrong page or come from a wrong link that is removed. How you can add your own 404 page can be found in the knowledge base. In this way you catch a lot of annoyance from a user. Try to refer on your 404 page to resources on your hosting space that may be able to help your customers; for example to the contact page or home.

You can do the same for a 500 error. For example if there is an error in the code or you are working on an update.

Show all error messages for ASP.NET

To show error messages for most things in ASP.NET you can apply the following code.

Use Response.IisTrySkipIisCustomErrors

Context.Server.ClearErrors()Context.Response.IisTrySkipIisCustomErrors

After this, add the following to the web.config file:

<httpErrors existingResponse="Passthrough" />.

This can be done between the system web server tags.

The above modification ensures that all error messages come through with HTTP responses.

CustomErrors in IIS

This is the most used option and is also enabled by default with the fast web hosting of MijnHostingPartner.nl. By default this is set as follows when the package is created:

   <httpErrors errorMode="DetailedLocalOnly" existingResponse="Auto" />

This can be changed to RemoteOnly to see local error messages, however this is only applicable when you host this locally. To see the error messages with us, this can be changed to 'OFF'. With the status 'ON' you will get the standard HTTP error codes from MijnHostingPartner.nl.

Hosting at MijnHostingPartner.nl

We hope this will help you with the development of your ASP.NET website. On all our hosting packages it is possible to use ASP.NET. The latest version ASP.NET Core can only be used with the ASP.NET Core hosting package. If you have any questions about the packages do not hesitate to contact us via the online chat!

Inspiration from this blog post:

https://weblog.west-wind.com/posts/2017/Jun/01/Bypassing-IIS-Error-Messages-in-ASPNET