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">
    <system.webServer>
    <httpErrors errorMode="Custom" existingResponse="PassThrough">
    </httpErrors>
    </system.webServer>
  </location>

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

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?