Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement a "maintenance mode" in asp.net core

How could you implement a site-wide "Maintenance mode" for your Asp.Net Core app?

Requirements:

  • All controller requests respond with the same static "Maintenance mode" page
  • You need to be able to flip a switch in the backend to turn maintenance mode on and off (so it has to happen at runtime)

My current best idea is an actionfilter on all controllers, where I check for the maintenance mode in code (bit in a database) and just return the maintenance mode page if maintenance mode is true.

like image 428
Kjensen Avatar asked Oct 23 '25 15:10

Kjensen


1 Answers

From the Microsoft docs, you can use the standard app_offline.htm mechanism:

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.1#app_offlinehtm-2

like image 95
DvS Avatar answered Oct 26 '25 17:10

DvS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!