App Offline file app_offline.htm
This article contains information about app_offline.htm file.
File app_offline.htm
The app_offline.htm file is a special mechanism within ASP.NET/IIS (Internet Information Services) that allows temporarily taking a web application or website offline, for example, during updates or maintenance. When this file is placed in the root directory of the web application, IIS automatically stops processing requests for the application and instead returns the content of the app_offline.htm file for all incoming requests.
How does it work?
1) File Detection:
- IIS checks for the presence of the app_offline.htm file in the root directory of the application for every request.
- If the file is found, IIS stops the application (including terminating any running worker processes) and redirects all requests to this file.
2) Serving the File's Content:
- The content of app_offline.htm is returned as the response to all HTTP requests.
- A typical use case is displaying a user-friendly message such as "The application is temporarily unavailable, please check back later."
3) Restoring Operation:
- Once the app_offline.htm file is removed, IIS restarts the application (reinitializing new application processes) and processes requests as usual.
What does the app_offline.htm file look like?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temporary Unavailability</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
color: #555;
}
h1 {
color: #333;
}
p {
font-size: 18px;
}
</style>
</head>
<body>
<h1>The web application is temporarily unavailable</h1>
<p>We are performing maintenance. Please try again later.</p>
</body>
</html>
When to Use the app_offline.htm File?
- During the deployment of a new version of the application, when you need to temporarily disable user access.
- When performing server maintenance or making changes to the web application’s configuration.
- When debugging an issue or fixing a problem.
Benefits:
- Simple Implementation: You only need to create an HTML file and place it in the root directory.
- Automatic Application Shutdown: The application is automatically stopped without manual intervention.
- Clear Communication: Users receive a clear message about the temporary unavailability.
Important Notes:
- Maximum File Size: The app_offline.htm file should not exceed 512 KB, or IIS will ignore it.
- If you deploy the application using tools like Visual Studio or MSDeploy, these tools may automatically create and delete the app_offline.htm file during the deployment process.