Click here to Skip to main content
15,121,963 members
Articles / Web Development / HTML
Technical Blog
Posted 20 Jul 2011

Tagged as


6 bookmarked

Best Way to Put Your ASP.NET Site Offline

Rate me:
Please Sign up or sign in to vote.
2.50/5 (2 votes)
20 Jul 2011CPOL2 min read
A clean, fast and stand-alone solution

OK, the "best way" can be arguable, but this sure is a clean, fast, and stand-alone solution.

In a perfect world, we would never ever need to put our site offline... never!... but we're all grown up now and there's no such thing as a perfect world, and we need to put our sites into a comma stage so we can begin surgery without thinking about outside factors.

The Trick: app_offline.htm

There are many ways of putting your ASP.NET website offline but the fastest way is to just drop a file named app_offline.htm on the site's root. Tcharan! That's it folks, good night! :)

OK, not so fast, I have one more trick up my sleeve.

As you can imagine, this app_offline.htm file can contain HTML markup which will be returned to the user. So you can build your offline page all in there in plain HTML for your users to see. As long as you have this file on the website root, all requests to anything on that website will be redirected to this offline page... and this leads us to a problem...

Showing Images on app_offline.htm

This is nice till the point you try to show an image on that page. Like I said above, all requests to anything on this website will be redirected to the app_offline.htm file, and that includes any image file you might want to show on your cute offline page.

To overcome this, you have two options:

  1. Reference an external image file with a URL that points to another site
  2. Embed the image file right on the markup

Embedding Images Inside the app_offline.htm

<img> tags have the ability to consume more than direct pointers to image files, they can read Base64. So the idea is to convert our images into Base64 and inject that code on our page:

<img class="undermaintenanceimage" src="data:image/png;base64,[BASE64 DATA]" />

Just replace [BASE64 DATA] with your image in Base64 format.

If you don't know how to convert an image into its Base64 representation, you may use one of the services online that does that for you; try this one for example.


This way, you can create a simple and stand-alone offline file without having to worry about external references or much harder to maintain techniques.

This article was originally posted at


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Switzerland Switzerland
Senior IT Consultant working in Switzerland as Senior Software Engineer.

Find more at on my blog.

Comments and Discussions

-- There are no messages in this forum --