Click here to Skip to main content
15,911,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Comments
ZurdoDev 27-Feb-15 7:57am    
Have you done any research? I believe SQL has a synchronization option to where you can store the db client side and synch it up.
Sergey Alexandrovich Kryukov 27-Feb-15 9:18am    
No problem. Many applications are like that. It all depends on what functionality should be implemented.
As you did not bother even to mention it, I suggest you start from learning how Web works.
—SA

1 solution

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.


Please read about the use of Web storage, which is implemented by two embedded objects, localStorage and sessionStorage:
http://en.wikipedia.org/wiki/Web_storage[^],
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage[^],
https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage[^],
https://developer.mozilla.org/en-US/docs/Web/API/Storage[^],
https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API[^].

Be careful with localStorage, as it is stored permanently. The user can always remove it, but it's not nice, because it would need digging into browser's setting and can lead to removal of unrelated but valuable data. You need to provide a capability of cleaning storage related to your application:
https://developer.mozilla.org/en-US/docs/Web/API/Storage/removeItem[^],
https://developer.mozilla.org/en-US/docs/Web/API/Storage/clear[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900