adgteq
adgteq

Reputation: 83

Creating a standalone windows application from an ASP.NET website

I am developing an ASP.NET website. The users can open up the web page and work with data when they are online. But I want to make them able to work when they are offline and submit their changes later when they are online again. The offline application must be very simple to run and I don't want to develop a separate windows application for this purpose.

So I want to build an executable that when starts, first starts up a local IIS and then opens the startup page of my website (which is locally available) in the user's browser.

And of course it would be great if this executable can be installed on the user's system along with my website files, IIS and SQL Server Express all in one package.

Upvotes: 2

Views: 4398

Answers (2)

Pradeep Kumar
Pradeep Kumar

Reputation: 6979

OK I re-read your question and see that you will have local IIS and local Database installed on all client systems.

So then the solution is very simple.

The Applicaiton (main form)

  1. Create a windows forms application.
  2. Put a WebBrowser control and a StatusStrip control on the form.
  3. Add two string resources named say LocalStartUrl and OnlineStartUrl, which holds the addresses of your local and online website home/startup pages.
  4. On Form_Load, check for online internet connectivity and accordingly launch either LocalStartUrl or OnlineStartUrl in the webbrowser control. You can show messagebox and use the StatusBar to inform the user of the same.

The sync module:

The database sync module runs in the timer/separate thread and synchronizes your local database with online database in the background. It sends any unsaved changes to the server and downloads any missing data from the server to local database. You would need to control the speed of this module so that user doesn't face difficulty browsing other websites or using the application smoothly etc. It should be slow and steady and send/request only small chunks of data at a time.

When in offline mode, it just periodically checks for online connectivity at regular intervals. As soon as an internet connectivity can be found, the user is informed. If they permit, it switches over to online mode. Otherwise the user continues to work offline until the application is closed and launched again.

In online mode, the sync module syncs data to & from the online database. This doesn't affect the user because they are not connected to this database. Instead they are connected to the online website and database.

It will take efforts to streamline this approach, but ultimately it is achievable easily.

Upvotes: 1

Pradeep Kumar
Pradeep Kumar

Reputation: 6979

This won't be just a single task. It would be a series of task working together in sync.

Your windows application does the following:

  • Write the offline changes to a disk file/database etc.
  • Periodically check the online availability of your website/ftp site.
  • Whenever the website is found to be available, and there are some cached changes, submit the file to the website/ftp site.

Your server does the following:

  • Whenever a file is recieved, check for its validity and integrity. If found correct, put it in a specific folder.
  • A service on your server watches the folder and as soon as any file is found there, processes the file(s)
  • The service moves the file to another folder (backup) after processing.

Upvotes: 0

Related Questions