jd2011
jd2011

Reputation: 1

Updating a webpage from a desktop aplication

I've written a desktop application in VB.net which gets data from numerous serial devices and graphs it in a windows form. What I'd like to do enable remote users to view this data remotely from a web browser.

So, is it possible to add a webpage to a desktop application which could be dynamically updated from from my windows app or do I have to rewrite the entire application in asp, flex or silverlight so it can be viewed remotely via a web browser?

I'm not familiar with asp flex or silverlight and have only developed desktop apps using vb.net 2010 on win7 and XP. So any advice or direction in the sinplest possible terms would be appreciated.


I posted the original question some months back and have only recently begun to research the suggestions made. Thanks to all for your help so far and I hope you can advise me further.

So I've implemented the HTTPListener suggestion (cobbled together from MSDN examples) and it works but the webpage it serves is less than exciting, to say the least. Really what I need is your opinions on what I'm doing and to see firstly, if its the best way to do it and secondly to see what are the security implications if users can access the PC on which my app is running via a web browser. The following is a description of what I've done so far, I'll try keep it as brief as I can.

The application gathers data from serial devices connected to the PC, does some calculations and stores the results in a local SQLCE database. The HTTPListener serves a very basic webpage on which I have (so far) 3 buttons, each of which redirects the browser using HTML 'location.href' ,which the httplistener receives. I parse the request using 'request.Url.Query' for particular key words. If the keyword 'result' is received, I generate a HTML string from an datatable, which stores the DB results and serve that string via the httplistener.

The other two buttons invoke delegates which run functions in my application like "begin collecting data from serial devices" and "start a graphing sub". So really I'm using the httplistener to remotely control my application. I suspect this may not be the best way to do this? I get the sense that I'm hacking a solution rather than doing this properly.

Any advice or direction would be appreciated. I can post the code too if needed, embarrassing as that might be.

thanks again for the help, its badly needed.

JD2011

Upvotes: 0

Views: 611

Answers (5)

Christian Klauser
Christian Klauser

Reputation: 4466

Another approach is to have your desktop application generate static html files and images (the graphs) and serve those via IIS, Apache or any other web server.

This web server could also be on another machine and you'd use either network drives or FTP to upload the most up-to-date html and image files.

The class System.Net.FtpWebRequest allows you to perform FTP transactions directly from your desktop application.

Upvotes: 1

Christian Klauser
Christian Klauser

Reputation: 4466

You can have your application act as a web server using the HttpListener class (System.Net namespace).

This approach has the following consequences:

  1. Your application has to run for the web page to be accessible
  2. Remote viewers have to connect to the computer the desktop application runs on
  3. You have to write logic for those web pages 100% by hand. There is no framework to support you (like with ASP.NET). You literally have to write every byte in the HTML page that the remote viewer receives yourself.
  4. Since #1, every instance of your desktop application will have its own web page.

Overall, the scope, in which HttpListener approach is the best option, is very limited.

Upvotes: 0

Maysam
Maysam

Reputation: 7367

You can embedded a Browser control into your desktop app and use any webpage.

Upvotes: 0

Random Dev
Random Dev

Reputation: 52290

do let remote users see this your computer must be "reachable". So it has to be online and in the DMZ, ... I would recommend writing these data into a database/file and write a seperate application running to view it in ASP.NET or whatever you like.

Upvotes: 1

Related Questions