tags:

views:

1184

answers:

3

When using the app_offline.htm feature of ASP.NET, it only allows html, but no images. Is there a way to get images to display without having to point them to a different url on another site?

+7  A: 

Yes, it just can't come from the site that has the app_offline.htm file. The image would have to be hosted elsewhere.

Ryan Farley
+2  A: 

If your willing to do a little more work you can easily create your own pages to take your application offline.

One possible solution:

  • Create DisplayOfflineMessage.aspx: Contains label to display your offline message from Application["OfflineMessage"].
  • ManageOfflineStatus.aspx: Contains an offline/online checkbox, textarea for offline message and an update button. The update button sets two application level variables, one for the message and a flag that states if the application is online. (This page should only be accessible to admins)

Then in Global.asax

 public void Application_Start(object sender, EventArgs e)
 {
     Application["OfflineMessage"] = "This website is offline.";
     Application["IsOffline"] = false;
 }



 public void Application_OnBeginRequest(object sender, EventArgs e)
 {
     bool offline = Convert.ToBoolean(Application["IsOffline"]);

     if (offline) 
     {

         // TODO: allow access to DisplayOfflineMessage.aspx and ManageOfflineStatus.aspx

         // redirct requests to all other pages
         Response.Redirect("~/DisplayOfflineMessage.aspx");
     }
 }
Aros
A: 

I have an idea.

You can create separate application, pointed to the same folder, without ASP.NET enabled. Then accessing to images by this application will not be affected by app_offline.htm file. Or, point that application direсtly to folder with static content, there will not be any app_offline files.

But, of course, you need to assign separate dns name for this application, kind of static.somedomain.com.

derigel