Returning custom response code for serving static html when using IIS ApplicationInitialization remapManagedRequestsTo?

I am currently using the ApplicationInitialization IIS function to warm up my ASP.NET application. I set the remapManagedRequestsTo attribute to "warmup.html" .

<applicationInitialization remapManagedRequestsTo="warmup.html" skipManagedModules="true" doAppInitAfterRestart="true" >
  <add initializationPage="/home" />  
  <add initializationPage="/about-us" />      
</applicationInitialization>

It works well, but I would like to return the user 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 find out when the warm-up ended.

I tried using the Rewrite URL to change the status code from 200 to 555 to serve warmup.html and it changes the status code but does not serve the contents 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 that I can execute as a service warmup.html content AND return a status code of 555 ? p>

+2
source share
1 answer

Finally found my answer on a blog written by Morten Bock

, remapManagedRequestsTo skipManagedModules ( false),

<applicationInitialization doAppInitAfterRestart="true">
  <add initializationPage="/home" />  
  <add initializationPage="/about-us" />      
</applicationInitialization>

URL Rewrite , , , APP_WARMING_UP, 1. , statusCode 555.

<rewrite>
    <rules>
        <rule name="WarmUp" patternSyntax="Wildcard" stopProcessing="true">
            <match url="*" />
            <conditions>
              <add input="{APP_WARMING_UP}" pattern="1" />
            </conditions>
            <action type="CustomResponse" statusCode="555" statusReason="Site is warming up" statusDescription="Try again shortly" />
        </rule>
    </rules>
</rewrite>

, 555 warmup.html

<system.webServer>
    <httpErrors errorMode="Custom">
        <error statusCode="555" path="warmup.html" responseMode="File" />
    </httpErrors>
</system.webServer>
0

All Articles