在离线和/或在线开发Web应用程序工作 [英] Develop a web application work in offline and /or online

查看:72
本文介绍了在离线和/或在线开发Web应用程序工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的

需要使用.net驱动的SQL Server数据库开发Web应用程序,该数据库也可以在离线环境中运行。



客户希望它在线工作(如果有互联网连接)和离线(如果没有互联网连接)。由于我是asp MVC的新手,我不知道开发这个应用程序。我如何开发此应用程序。

Dear
There is a requirement to develop a web application using .net driven with SQL Server database which should also work in an offline environment.

Client wants it to work online (if internet connection is available)and offline(if no internet connection).As i am new to asp MVC I don't know to develop this application. How can i develop this application.

推荐答案

请参阅我对该问题的评论。由于你的功能尚不清楚,我只会给你一些基本的想法,加上一些我认为是关键的建议。



首先,你所有的客户-side行为是使用JavaScript定义的。 (我不算使用CSS实现的琐碎行为元素,他们只能改变视图,不能改变任何数据。)



通常,如果你在线,你通过单击锚元素发送大多数或所有HTTP请求,有时通过某些表单的提交按钮发送。即使对于断开连接的用户,这也会起作用,因为任何人都可以从错误页面返回到上一页,但对用户来说看起来不太好。因此,我建议您通过Ajax创建HTTP请求系统以响应用户UI操作: http:// en.wikipedia.org/wiki/Ajax_%28programming%29 [ ^ ]。



使用Ajax,您始终可以处理指示失败的响应(由于缺少连接,根据您的要求),以及而不是转到错误页面,只需在您的UI上显示它。



使用Ajax的一种便捷方式是使用jQuery: http:// api.jquery.com/category/ajax [ ^ ]。



使用.NET,您可以使用一个或另一个Ajax框架: http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#.NET [ ^ ]。



如您所知,所有离线资源将随时可用,应用程序页面已经加载到浏览器中(甚至从浏览器缓存加载),但在断开连接后,所有Web资源都将完全不可用。根据所需的功能,它使您有机会仅在客户端支持许多不同的用户操作。但是可以使用哪些资源?不多。考虑一下:


  • 您可以使用JavaScript修改页面的DOM结构,并且可以使用DOM包含的数据,因为它保持不变。
  • 您可以使用local sessionStorage 对象并在会话期间保留其中的任何数据,当您保持浏览器打开它的应用程序页面时,这些数据不会被破坏。
  • 您可以在会话之间使用永久 localStorage
Please see my comment to the question. As your functionality is not known, I'll give you only the basic idea, plus some suggestions I consider as the key ones.

First of all, all your client-side behavior is defined using JavaScript. (I don't count trivial behavior elements achieved using CSS, they only can change the view, cannot change any data.)

Normally, if you are online, you send most or all HTTP requests by clicking on anchor elements, sometimes by Submit button of some forms. This will "work" even for a disconnected user, because anyone can always go back from the error page to a previous page, but it would not look nice to the user. Therefore, I suggest you do create the system of HTTP request in response to the user UI action through Ajax: http://en.wikipedia.org/wiki/Ajax_%28programming%29[^].

With Ajax, you can always handle the response indicated failure (due to lack of connection, per your requirement) and, instead of going to an error page, just show it on your UI.

One convenient way of using Ajax is using jQuery: http://api.jquery.com/category/ajax[^].

With .NET, you can use one or another Ajax framework: http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#.NET[^].

As you understand, all off-line resources will be available anytime, as soon as the application page(s) is already loaded in the browser (or even loaded from the browser cache), but after disconnection, all Web resources will be completely unavailable. Depending on the required functionality, it leaves you the opportunity to support a lot of different user operations on the client side only. But what resources can be used? Not many. Consider this:

  • You modify the page's DOM structure with JavaScript and can use data contained by DOM, as it remains intact.
  • You can use local sessionStorage object and keep any data in it during the session, which won't be broken while you keep the browser open it your application page(s) loaded.
  • You can use permanent localStorage between sessions.


这篇关于在离线和/或在线开发Web应用程序工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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