构建具有离线功能的 ASP.Net Web 应用程序 [英] Build an ASP.Net web app with offline functionality

查看:26
本文介绍了构建具有离线功能的 ASP.Net Web 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 asp.net (3.5) 网络应用程序,想知道您是否知道我可以通过什么方式来实现它以便有一些离线功能.

I'm in the process of building an asp.net (3.5) web app and was wondering if you knew of any way I could do it so that there would be some offline functionality.

这是必需的,因为人们将能够在他们的设备上安装"网络应用程序(例如使用 iPhone 上的添加到主屏幕"功能),然后在离线时使用该应用程序;使用只会受到限制(此时也不需要服务器调用).

This is needed as people will be able to 'install' the web app on their device (using the 'Add to home screen' function on an iPhone for example) and then use the app when they are offline; the usage would only be limited (there would be no need for server calls at this point either).

这可以通过 .aspx 页面完成吗?

Can this be done with an .aspx page?

编辑 - .manifest 添加:

Edit- .manifest added:

CACHE MANIFEST
index.aspx

/logo.png
/main.css
/main.js

编辑 2-

我们让它以某种方式离线工作;它在 safari 中有效,但我们不希望在 safari 中使用它,我们希望它作为一个独立的应用程序.当我们尝试像这样运行它时,我们会收到无法连接到服务器错误".这可以通过 .aspx 页面实现吗?

We have it working offline, in a fashion; it works when in safari but we don't want it in safari, we want it as a standalone app. When we try to run it like this we get the 'can't connect to server error'. Is this possible with a .aspx page?

编辑 3 -

我们已经使用 .html 页面使其工作,但还没有使用 .aspx

We've got this to work using a .html page but still not yet with an .aspx

编辑号 4-

它现在可以工作了,虽然我们不确定为什么!上周我们将 index.aspx 添加到 cache.manifest 的网络"部分(上周没有用!)这可能有所帮助,但一旦我确定我会向您更新实际发生的情况!

It's now working, although we're unsure why! We added the index.aspx to the 'network' section of the cache.manifest last week (which didn't work last week!) which may have helped but once I know for sure I'll update you with what actually happened!

感谢大家的帮助!

推荐答案

对于使用 ASP.NET 的离线 HTML5 应用程序,请参阅此 链接 和这个链接.

For offline HTML5 applications with ASP.NET, see this link and this link.

对于离线功能,有一些替代方案:

For offline functionalities, there are some alternatives:

01 - 如果您需要在离线应用程序中存储少量数据,并且安全性不是一个大问题,您可以使用 HTML5 Web Storage (链接链接链接link, 链接,并查看 CanIUse 以了解浏览器版本支持).

01 - If you need to store small amounts of data in the offline application, and security is not a big concern, you can use HTML5 Web Storage (link, link, link, link, link, and take a look at CanIUse for understand browser version support).

主要缺点是缺乏安全性,是基于键值的(没有复杂的结构),并且存储大小有很大的限制(大多数浏览器为 5MB).

The main disadvantages are that it lacks in security, is key-value based (no complex structures) and there is a big limitation in storage size (5MB for most browsers).

02 - 如果您需要大量数据,可以查看 IndexDB (链接链接linkCanIUse) 或 Web Sql (链接linklinkCanIUse 用于浏览器支持).

02 - If you need larger amount of data, you can look at IndexDB (link, link, link and CanIUse) or Web Sql (link, link, link and CanIUse for browser support).

Web SQL 的主要缺点是 Firefox 和 IE 不支持它.此外,它已被 W3C 弃用.

The main disadvantages of Web SQL are that it is not supported by Firefox an IE. Also, it is deprecated by W3C.

IndexDB 很好(link),不过好像ios还是不支持(看canIUse).

IndexDB is good (link), but it seems like ios still doesnt support it (see canIUse).

对于方法 1 和 2,您可以在 ASP.NET 应用程序中制作响应式设计或专用移动网站 (链接).

For approaches 1 and 2, you can make a responsive design or a dedicated mobile web site in your ASP.NET application (link).

03 -(更大的灵活性需要更多的努力)在您的 ASP.NET 应用程序和应用偶尔连接的应用程序概念的移动本机应用程序中实现 Web 服务(更多信息:链接链接)

03 - (greater flexibility demands more effort) Implement an Web Service in your ASP.NET application and a mobile native app applying concepts of Occasionally Connected Applications (more info: link, link)

  • ASP.NET Web 应用程序 => 对于 Web 应用程序,公开具有与离线功能相关的服务的 Web 服务.

  • ASP.NET Web Application => For the web application, expose a Web Service with services related to the offline functionality.

移动应用 => 使用应用的数据库实现原生移动应用(例如,为 Android 和 iPhone 开发应用).然后,您在移动应用中创建离线功能,该功能将使用自己的数据库读取和写入(本地)必须离线使用的数据.

Mobile application => Implement a native mobile app (e.g., develop an app for android and iphone) with a database for the application. You then create the offline functionality in the mobile app that will use its own database to read and write (locally) data that must be available offline.

然后,您在依赖 Internet(例如循环线程)的移动应用程序中实现静默同步机制,该机制将通过 Web 服务访问 ASP.NET 应用程序来搜索更新.此同步机制将发送本地存储的数据,并从 Web 服务中恢复对离线功能有用的数据.

You then implement a silent synchronization mechanism in the mobile app that relies on internet (e.g. a recurrent thread) that will search for updates by accessing the ASP.NET application via Web Service. This sync mechanism will send the data that was stored locally and recover data from the Web Service that can be useful for the offline functionality.

希望有帮助.

这篇关于构建具有离线功能的 ASP.Net Web 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆