This is quite an odd question, but I am trying to test the Web.Config settings for custom errors e.g.:
<customErrors mode="On"/>
<error statusCode="500" redirect="500.html"/>
<error statusCode="500.13" redirect="500.13.html"/>
</customErrors>
Is there anyway I can create a page or intercept the request in the global.asax Application_BeginRequest method that can fake up a response to send to the browser i.e. setup a 500.13 HTTP error status which tells IIS to use the 500.13.html page defined in the Web.Config.
Ideally, I'd like to do something like create a page that takes a query string value of the status code I want returned e.g. FakeRequest.html?errorStatus=500.13 so that our testers can make sure the appropriate page is returned for the various errors.
Try something like:
protected void Page_Load(object sender, EventArgs e)
{
var rawErorStatus = HttpContext.Current.Request.QueryString.Get("errorStatus");
int errorStatus;
if (int.TryParse(rawErorStatus, out errorStatus))
{
throw new HttpException(errorStatus, "Error");
}
}
Found this at the following page: http://aspnetresources.com/articles/CustomErrorPages
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With