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

前端 未结 6 2014
甜味超标
甜味超标 2020-12-29 04:37

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 speci

6条回答
  •  温柔的废话
    2020-12-29 05:16

    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!

提交回复
热议问题