0

So I have here a .NET C# web app that needs one page able to be viewed offline as a user could be off in the middle of 'whoop whoop' with no internet.

The order of events are:

  1. User visits a form online
  2. Store the webpage using HTML5 so they can visit it later offline
  3. When online - the user then can submit the form to the database

I've been looking over HTML5 appcache however it seems to only reference physical .html or .php pages rather than storing pages which have been generated by 'Razor' .cshtml Views.
e.g. domain.com/path/view.
I haven't been able to find any relevant documentation for my problem either.

So is it possible to cache a .NET webapp ofline?

2 Answers 2

1

Although I have not tried it, and assuming your app uses ASP.NET MVC, this might help you: Build an HTML5 Offline Application with Application Cache, Web Storage and ASP.NET MVC

It uses HTML5 Offline Web Application API (or HTML Application Cache). Note the comment on browser support.

The linked article shows a sample application, but I could not see a link to a downloadable source code. But one commenter appears to have recreated the project.

Sign up to request clarification or add additional context in comments.

4 Comments

Came across this site recently while researching but skipped over it as it seems to have a lot of information repeated elsewhere. If it's helpful to me I'll mark your answer as correct.
Basically, you need the page you want offline to have <html manifest="{manifest_name}">, and that manifest file defines which related resources are accessible offline, or online only. So with MVC, you can use a different layout.cshtml for pages you want to be available offline. Or in the case of the linked article, the View has no layout page, and instead has the html tag with the manifest attribute.
hrmm it seems to not like the manifest MIME type. Getting a AppCache Fatal Error in IE, Application Cache Error event: Failed to parse manifest in Chrome and Application Cache manifest had an incorrect MIME type: text/html in Safari. Almost bashing my head upon the table at this point :(.
Your manifest should be served with mime type "text/cache-manifest". You can check the section "What to configure in IIS" in this blog
0

The appcache is what you need. Note that you specify the pages to be cached, but the browser never sees if the page is a static .html or generated via Razor. As long as the path you specify opens the right page, it will be cached.

1 Comment

can you post an example or relevant documentation?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.