Question

Is there any way that I can return 500.13 error from IIS? I need the test the custom error page for 500.13 error.

Was it helpful?

Solution 2

You can't raise a "server busy" error from the code. You can simulate the error codes as shown in the other answer but it will not allow you to determine if your custom error page will be shown correctly as the whole point to the "server busy" error is that code cannot be executed - so it is very safe assumption that IIS will do something different to raise this kind of error.

But from what I can see the 500.13 error was thrown by ASP, not ASP.NET applications. Instead for ASP.NET applications you would see 503 Service Unavailable error.

You can trigger 503 status code with the following:

  1. Open IIS Management Studio, go to Application Pools, open Advanced Settings for your app pool and change Queue Length to 10 (the minimum).
  2. In your ASP.NET application add a call to Thread.Sleep(50000).
  3. Now start pounding the web server - pretty soon you will get 503 Service Unavailable error back.

OTHER TIPS

I don't believe IIS includes simulation of errors, however, there are benchmarking/stress testing applications out there that you can use. The only drawback to this is that you will actually have to put your (test?) server under actual stress until IIS "breaks."

First, you should lower the IIS Application Pool size to the minimum available.

IIS - Application Pool Queue Length

I suggest you use Apache's JMeter. It's relatively simple to get a handle on and use.

Once you've gotten it downloaded and running, here are the basic steps to perform some stress testing:

  1. Add a "Thread Group" - the thing that makes it all work JMeter - Add Thread Group

  2. Set Thread Group parameters - here you set the number of concurrent threads (i.e. users) JMeter - Set Thread Group parameters

  3. Add HTTP Request to Thread Group - this is a test step. JMeter - Add HTTP Request to Thread Group

  4. Set HTTP Request parameters - here you specify the web address (localhost, www.yourdomain.com, etc.), along with any other configuration you require JMeter - Set HTTP Request parameters

  5. Add Reports - reports are how you view results, along with server requests and responses JMeter - Add Reports

  6. Run the Test Plan and view the Results JMeter - Run Test Plan and View Results


Finally, once you are running the test and viewing failures, you can browse to your server under your preferred browser and view the results live.


EDIT

In case you have access to multiple computers/servers, you can even try distributed stress testing. The tutorial is available on their site.

Put this in the Page_Init event:

protected void Page_Init(object sender, EventArgs e)
{
    Response.Clear();
    Response.StatusCode = 500;
    Response.SubStatusCode = 13;
    throw new Exception();
}

But AFAIK, there's no way to set the subcode error in the customErrors section of Web.config. You can, however, check the subcode in Global.asx Application_Error event:

int subCode = HttpContext.Current.Response.SubStatusCode;

If you follow the logic, you can simulate any IIS error.

You could use a framework to simulate load. Selenium Grid may help.

Visual Studio Team System too can simulate load, however it is not free.
Take a look at Load Testing with Visual Studio Team System

This is a similar question on StackOverflow. Is this a match with what you're trying to accomplish? Faking Http Status Codes in IIS/.net for testing

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top