且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

构建具有离线功能的 ASP.Net Web 应用程序

更新时间:2022-11-06 20:05:18

对于使用 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.

希望有帮助.