12

Well, I'm trying to make custom app_offline.htm and want to add links to my css files in project. But next code doesn't work

<link href="/Content/Themes/screen.css" rel="stylesheet" type="text/css" />

In console I've got error

GET mySite/Content/Themes/screen.css 503 (Service Unavailable)

Please, give me advise how to make a link to css file in app_ofline.htm. Any help will greatly appriciated!

4 Answers 4

15

The idea of the app_offline.htm is that it indicates that the app is, well, offline. So, no resources are available from the site when the site is offline. Either put the relevant rules into the page or host the stylesheet on a separate domain.

9

You have to use inline css style for this instead of referring to external CSS file.

<style type="text/css">
    /* write your css code here */

</style>

App_Offline.htm

Basically, if you place a file with this name in the root of a web application directory, ASP.NET will shut-down the application, unload the application domain from the server, and stop processing any new incoming requests for that application. ASP.NET will also then respond to all requests for dynamic pages in the application by sending back the content of the app_offline.htm file (for example: you might want to have a “site under construction” or “down for maintenance” message).

8

You can add it as base64 in the img tag... like this:

<img src="data:image/png;base64,<64-bit string goes here> alt=""/>

This works at least for an image that says the site is under construction.

1
2

You can't link to it. It's offline. Unless you're using a remote css file that you can guarantee will be in a functioning server the css file will not be allowed to be served because the .Net Framework restrictions have been put in place to forbid the serving of any file except app_offline.htm. You can either put your css inline with the page or host it on a separate site (which is a choice some companies make anyway to keep design elements in a common location for enterprise applications).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.