Learn how to use Asp .Net Core’s framework feature or code your own implementation
In this article, you will both learn how to put your asp.Net Core app into maintenance mode using the framework’s “App offline file” feature, and how to implement your own maintenance mode logic when you need more control.
Let’s start with the fast solution when you just need to put it in maintenance quickly.
Using the framework’s maintenance feature
For a fast implementation, you can use asp .Net Core’s maintenance feature by adding a file called “app_offline.htm” in the root of your solution. This is a very nice, quick and easy solution that lets you create a HTM(L) file with the layout and message that you want to show to your users you are performing maintenance on the app.
This feature is called the “App offline file”, and has some things to consider, like:
- the file can be maximally 4Gb in size (should be more than enough)
- it needs your app to receive another request to become online after removing the file
- in specific situations, the app might not shut down immediately
You can read Microsoft’s documentation on the App Offline file feature, here:
App Offline file (app_offline.htm)
The App Offline file ( app_offline.htm) is used by the ASP.NET Core Module to shut down an app. If a file with the name…
The App Offline file feature is very nice for small projects, MVP’s or demo setups, and side projects.
If you want more control of how to implement maintenance mode, and want to add logic- or signalling features for a more controlled process, you will need to code your own solution. I will explain this in the following part.