I'm currently using the ApplicationInitialization feature of IIS to warm up my ASP.NET application. I've set the attribute remapManagedRequestsTo to "warmup.html".
<applicationInitialization remapManagedRequestsTo="warmup.html" skipManagedModules="true" doAppInitAfterRestart="true" >
<add initializationPage="/home" />
<add initializationPage="/about-us" />
</applicationInitialization>
It's working well but I would like to return a custom status code when the content for Warmup.html is returned to the browser. This is so that when I run some smoke tests after deployment I get to know when the warm up has finished.
I've tried using URL Rewrite to change the status code from 200 to 555 to serve up warmup.html and it does change the status code but doesn't serve the content in warmup.html
<rewrite>
<rules>
<rule name="Change warm up status code" stopProcessing="true">
<match url="warmup.html" />
<action type="CustomResponse" statusCode="555" subStatusCode="0"/>
</rule>
</rules>
</rewrite>
Is there a way I can do both the serving of warmup.html's content AND return a custom status code of 555?
Finally found my answer in a blog post written by Morten Bock
Turns out I have to remove the two attributes remapManagedRequestsTo and skipManagedModules (default value of false) which leaves us with
Then let the URL Rewrite module take over but we want to rewrite the response code when the Application Initialization is making the request marked by the server variable
APP_WARMING_UP
containing a value of1
. When this condition is met we can create a custom response as the action and pop the statusCode attribute with 555.Then to catch the status 555 as a custom error and direct the user to the friendly warm up page warmup.html