使用脱机功能构建ASP.Net Web应用 [英] Build an ASP.Net web app with offline functionality

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

问题描述

我正在构建一个asp.net(3.5)Web应用程序,想知道您是否知道我可以做些什么,以便有一些脱机功能.

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

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

编辑-已添加.manifest:

CACHE MANIFEST
index.aspx

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

编辑编号2-

我们以某种方式使其脱机工作;在safari中时可以使用,但我们不希望在safari中使用它,我们希望将其作为独立的应用程序使用.当我们尝试像这样运行它时,我们得到无法连接服务器错误". .aspx页面可能吗?

编辑3号-

我们已经可以在.html页面上使用此功能,但仍无法在.aspx上使用

编辑编号4-

它现在正在工作,尽管我们不确定为什么!我们将index.aspx添加到上周的cache.manifest的网络"部分(上周不起作用!)可能会有所帮助,但是一旦我确定我会向您更新实际情况!/p>

感谢大家的帮助!

解决方案

对于具有ASP.NET的脱机HTML5应用程序,请参见此链接.

>

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

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

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


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

Web SQL的主要缺点是Firefox和IE不支持它.此外,W3C不推荐使用.

IndexDB很好(链接) ,但似乎ios仍然不支持它(请参见canIUse).

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


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

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

  • 移动应用程序 =>使用用于该应用程序的数据库实施本机移动应用程序(例如,为android和iphone开发应用程序).然后,您可以在移动应用程序中创建离线功能,该功能将使用其自己的数据库来读取和写入(本地)必须离线可用的数据.

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


希望它会有所帮助.

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.

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).

Can this be done with an .aspx page?

Edit- .manifest added:

CACHE MANIFEST
index.aspx

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

Edit no.2-

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?

Edit no.3 -

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

Edit no.4-

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!

Thanks to all for your help!

解决方案

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

For offline functionalities, there are some alternatives:

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).

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 - 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).

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

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

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


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 Application => For the web application, expose a Web Service with services related to the offline functionality.

  • 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.

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.


Hope it helps.

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

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