views:

64

answers:

5

I have a WPF application, that I want to convert to an application running from the browser. The reason is that WPF doesnt run on Mac/Linux, and Silverlight is not an option because of it's security restrictions.

The basic idea is to turn the app into a webserver-like application, and handle the UI completely in html/ajax. This 'webserver' doesn't rely on WPF/Winforms, so can run on Mono as well. And you can even control the app from your Android/iOS device while on the road.

My question is: is it possible to create this user interface using .NET? The code for the webserver-part is not a problem, but i'm struggling with the actual html that is being served. For example, when someone clicks a button, I need to bind an event to that. I have to write lots of javascript for all those little 'events', for simple controls like listboxes, progress bars, etc. It would be so much easier if I could design the web-interface from VS. While it has support for ASP, I cannot use it's page designer, because the end-user will not have an ASP server running on their desktop PC.

So what would be the best approach to design those dynamic pages using .NET? Or is it simply not possible?

EDIT: To make it more clear, it's not an internet application. The user runs the server-part locally, and connects to 127.0.0.1:80 to view the User Interface of the app.

EDIT II: Because their seems lots of confusion, let me give an example of a similar application: SABnzbd. It's a binary newsgrabber, that you install as a 'Windows Service', and can be controlled through your webbrowser. It's multi-platform, and written in Python. I want to take the same approach, only using (VB).NET

+1  A: 

Let me start by saying: Yes. You can create a web based UI using .Net.

Second, let me say that there is so much in your question that is incorrect, that its tough to know where I should begin.


Silverlight is not an option because of it's security restrictions

Huh?!?


The code for the webserver-part is not a problem

Why would you have to write your own web server? Ans why would you know how to do that, and not know what ASP.Net is?


While it has support for ASP, I cannot use it's page designer, because the end-user will not have an ASP server running on their desktop PC.

Huh?!? First, what does the page designer have to do with how the rendered html reaches the user? Second, your users will not need to have any server running on their machine. Your web server is the server. Your users will only need a browser.


The easiest way to convert your existing WPF application to a web application would be to convert it to Silverlight. If (as you say) you don't want to do that, then I suggest you look into ASP.Net. If you install IIS (free with Windows Server), you can deploy ASP.Net easily and for free. This will be able to serve content to machines that are Mac, Windows, Linux, etc. Your users will not need to have the ASP Server running on their machines. They only need a browser.

ASP.Net allows you to bind event handlers to events such as button clicks. It also allows you to generate your pages dynamically.

EDIT (to answer the edited question)

EDIT: To make it more clear, it's not an internet application. The user runs the webserver/http daemon locally, and connects to 127.0.0.1:80 to view the User Interface of the app.

If the user runs the web server and the client application locally, then what have you gained? If you want this application to run on multiple platforms, you'll still have to write your application to support those platforms (whether you're writing a web server or the GUI).

Gabriel McAdams
It's not that I dont want Silverlight, but my application needs to open sockets/write files/etc which are all things that Silverlight doesnt support (even not in elevated mode). And you misunderstoond my question, I made an 'Edit' above to make it clearer.
Joshua
Whether you use Silverlight or not, you will still have the security restrictions on the client. Javascript/AJAX cannot open sockets or write files either. You would have to do any of that on the server. Once you realize that, then the UI can be created however you want it to be created. Silverlight, JSP, html and javascript, etc.
Gabriel McAdams
"Why would you have to write your own web server? Ans why would you know how to do that, and not know what ASP.Net is?" <-- Because the application is not an internet-application, it needs to be run locally by the user.
Joshua
I addressed that in my modified answer.
Gabriel McAdams
"If the user runs the web server and the client application locally, then what have you gained?" That users can use the application remotely (from their phone) if they open their firewall. And that the application does not rely on WPF for UI anymore (which is not supported on the Mono framework).
Joshua
Accessing your PC from your phone really isn't as simple as opening a firewall port. A lot of ISPs no longer assign static IP addresses.
Simon Bartlett
"A lot of ISPs no longer assign static IP addresses." <-- That can easily be solved by services like DynDNS, etc.
Joshua
The more complicated you make things, the more liked they are to break or no wrong. Plus what happena if DynDNS has an outage?
Simon Bartlett
A: 

Security 101 - the client is considered hostile. Any client, in any architecture. There is nothing particularly insecure about Silverlight, so if that meets your other needs then use it. And validate everything at the server; which you need to do anyway.

Marc Gravell
There is nothing insecure about Siverlight, but it has many restrictions. I cannot open sockets to certain ports/access the filesystem/etc.
Joshua
A: 

Why not build a client application that uses GTK# for UI? - then it'll be usable on all platforms.

Simon Bartlett
Because it will be very nice if people can control the application remotely from their phone, and perform operations like Stop/Pauze/Resume. If I port it to GTK#, it means I also have to port the UI to Android/iOS, and still have to develop a Client-Server architecture, so that the phone-interface can send commands to the desktop-pc.
Joshua
+1  A: 

If you are willing to rewrite the GUI, why not just use GTK# or Winforms? Both run on Windows+Linux. Check http://stackoverflow.com/questions/796856/what-is-the-difference-between-gtk-and-windows-forms for a comparison.

CodeInChaos
Because it will be very nice if people can control the application remotely from their phone, and perform operations like Stop/Pauze/Resume. If I port it to GTK#, it means I also have to port the UI to Android/iOS, and still have to develop a Client-Server architecture, so that the phone-interface can send commands to the desktop-pc.
Joshua
A: 

The whole time I only thought of two possible solutions:

  • HTML5/AJAX client + .NET server app (mono-compatible)
  • Silverlight application (Out of Browser + Elevated Trust)

The problem with the HTML5/Ajax solution was that .NET offers no way to design the UI.

The problem with the Silverlight solution was that 'elevated trust' still doesnt gave me enough permissions.

CodeInChaos and Blindy pointed me in the right direction, the third solution:

  • Silverlight client + .NET server app

I wil use Silverlight only for the client-part, not the whole app. And communicate with the server .exe through localhost-connection (JSON or something similar). This way i can design the UI using .NET, have none of Silverlight's restrictions, and full access to filesystem/registry/sockets.

Joshua