开发者

Can you create a webbased UI using .Net?

开发者 https://www.devze.com 2023-01-20 03:28 出处:网络
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

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, bu开发者_如何学JAVAt 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


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).


If you are willing to rewrite the GUI, why not just use GTK# or Winforms? Both run on Windows+Linux. Check What is the difference between GTK# and Windows Forms? for a comparison.


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.


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


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.


Now you are stating that you will use silver-light for the web app. Does this not get rid of the whole reason you decided on a client-server architecture? Seriously, how many phones run silverlight? You can still use other computers, but that does not seem to be nearly the same useful as phones. Like a few others have suggested, use Gtk# for the UI. You will have to write Android/iOS ports either way.

0

精彩评论

暂无评论...
验证码 换一张
取 消