views:

79

answers:

2

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.

+2  A: 
throw new Exception();

This will generate a HTTP 500

Carlos Muñoz
That was exactly was I going to say (:
Erik Escobedo
Me too :) beat us to it!
Alex Key
Many thanks, this worked perfectly.
ger
+1  A: 

Hi,

I think you can do this by overriding page init and adding the 500 status code to the response like the following:

protected void Page_Init(object sender, EventArgs e)
{
    Response.Clear();
    Response.StatusCode = 500;
    Response.End(); 
}

Enjoy!

Doug