Take the 2-minute tour ×

I'm trying to build an ASP.NET MVC3 (with razor syntax) based web app with HTML5 offline possibility, but unfortunately it does not work properly.

I read a lot of tutorials from which I used a couple of things.

First of all, here is the relevant part of my _Layout.cshtml:

    <html manifest="@Url.Content("~/offline.appcache")">
    @Html.ActionLink("Profile", "Profile", "Accounts", null, new { id = "profile" })
    @Html.ActionLink("Logout", "Logout", "Accounts", null, new { id = "logout" })
    @Html.ActionLink("Register", "Register", "Accounts", null, new { id = "register" })
    @Html.ActionLink("Login", "Login", "Accounts", null, new { id = "login" })

Secondly, this is my CacheManifestHandler class:

    public class CacheManifestHandler : IHttpHandler
    public void ProcessRequest(HttpContext context)
    //don't let the browser/proxies cache the manifest using traditional caching methods.
    context.Response.ContentType = "text/cache-manifest";
    context.Response.ContentEncoding = Encoding.UTF8;

    context.Response.Write("CACHE MANIFEST" + Environment.NewLine);
    context.Response.Write("CACHE:" + Environment.NewLine);
    context.Response.Write("/Content/Main.css" + Environment.NewLine);
    context.Response.Write("NETWORK:" + Environment.NewLine);
    context.Response.Write("http://*" + Environment.NewLine);
    context.Response.Write("*" + Environment.NewLine);

    context.Response.Write("FALLBACK:" + Environment.NewLine);
    context.Response.Write("/ /Error/PageNotAvailableOffline" + Environment.NewLine);

Last but not least, I placed these lines in my web.config file:

    <remove name="CacheManifest" />
    <add name="CacheManifest" verb="GET" path="offline.appcache" type="CMSP.Utilities.CacheManifestHandler" />

The offline feature works, but the main problem is when a user logs on in online mode, it seems to nothing has happened. I have to refresh the page at least once, and than I can see that the user logged in. It is very annoying.

Is there any possible solution that the app does not use the offline application cache in online mode?

share|improve this question
What is the use of your manifest if you are only going to show an error page? –  ZippyV Nov 13 '12 at 14:47
@ZippyV Due to the " <html manifest="@Url.Content("~/offline.appcache")"> " tag in the _Layout.cshtml, the app stores any webpages (e.g. localhost:port/Home/Action) which use the _Layout.cshtml. –  Sandor Nov 13 '12 at 15:25
add comment

Your Answer



Browse other questions tagged or ask your own question.