ger ger - 4 months ago 39
ASP.NET (C#) Question

How to simulate an HTTP 500 error on my ASP.NET app?

I want to simulate this error so I can check a generic error page is displayed, not the HTTP 500 one, in light of the recent security vulnerability.

We include special processing in the site itself for 404 and 403 so I want to make sure that errors without special processing work too.

Answer
throw new Exception();

This will generate a HTTP 500