Change the application status page response code

When Sitefinity CMS is initializing or upgrading, if you request a page or a URL from the application, you are redirected to the application status page (response code 302).

The reason for redirecting to the application status page, instead of directly rendering it on the requested URL, is to tell the outside systems that interact with your application, such as search engine crawlers, that the requested URL is temporarily unavailable, but it will be available shortly. The outside systems do not do anything with the response received from this request. For example, the search engine crawler knows that the requested URL is temporarily redirected to a different one and it does not index this response, but instead, tries again later.

On the other hand, the application status page response code is 200, which means the service returned the expected content. While this is handled properly by the search engine crawlers, if you are calling a public REST service, which is served by your Sitefinity CMS application, from a third party application, you will not see the redirect to the Application status page (302) and you will get the final response status code which is 200. This behavior may cause unexpected results in your third party application, because 200 status code is the response status code of the application status page and the response contains the application status code HTML.

To get around this problem you have the option to change the response code of the Application status page to be different than 200. You can do this by adding a new parameter in the <appSettings> of the web.config with key sf:AppStatusPageResponseCode and value - the response status code you want.

EXAMPLE: <add key="sf:AppStatusPageResponseCode" value="503" />

IMPORTANT: If you change the application status page response code and you are using custom error pages where you handle this code, you need to instruct IIS to let the Application status response pass through, instead of serving your custom error page. This is because if the system is upgrading or restarting while a custom error page is requested, Sitefinity CMS will not be able to display the Application Status page properly, which is the expected behavior. Do this by adding a <location> tag for in your web.config for the sitefinity/status path as follows:
<location path="sitefinity/status">
    <httpErrors errorMode="Custom" existingResponse="PassThrough">

For more information, see Administration: Custom error pages code.

Was this article helpful?