我有一个 C# Windows 窗体应用程序。是否可以部署在网络上,让用户可以通过网络访问?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4561904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I have a C# Windows Forms application. Can I deploy it on web, so that users can access through web?
提问by Ravikumar
We have done a Windows based application useing C# (.NET 2.0, Visual Studio 2005). Now redoing this application web based, is a time and resource consuming process and which is next to impossible for me.
我们已经使用 C#(.NET 2.0,Visual Studio 2005)完成了一个基于 Windows 的应用程序。现在重做这个基于 Web 的应用程序,是一个耗费时间和资源的过程,这对我来说几乎是不可能的。
We need to host this, so that the user can access through the Internet.
我们需要托管这个,以便用户可以通过 Internet 访问。
Through RDPthe user can access the Windows application, but the issues here is more users can not operate simultaneously.
通过RDP用户可以访问 Windows 应用程序,但这里的问题是更多的用户无法同时操作。
Can it be hosted as a web application, so that the user can access it through browser?
是否可以作为 Web 应用程序托管,以便用户可以通过浏览器访问它?
回答by slugster
No, you cannot make it available directly via the web as you would a website, Windows Forms applications run directly on the client machine.
不,您不能像网站一样直接通过 Web 提供它,Windows 窗体应用程序直接在客户端计算机上运行。
What you can do is package it up as an MSI installer, so that the end user can easily install it, and then have access resources such as a database via the Internet (the simplest way to expose these resources is as a web service). If you choose to use this mechanism then you will only have to refactor part of your application, assuming that you have already structured it nicely into an n-tierapplication.
您可以做的是将其打包为 MSI 安装程序,以便最终用户可以轻松安装它,然后可以通过 Internet 访问数据库等资源(公开这些资源的最简单方法是作为 Web 服务)。如果您选择使用这种机制,那么您只需重构应用程序的一部分,假设您已经将它很好地构建为n 层应用程序。
Note that the user doesn't have to access these resources via the Internet though - your mention of users employing RDP would suggest that you have it sitting on an intranet, which means you may be able to "host" services such as a database on an machine that all the clients can see (and access) across the network. In this case all that may be required is to change any connection strings or paths you may have sitting in the configuration file of the application.
请注意,用户不必通过 Internet 访问这些资源 - 您提到使用 RDP 的用户会建议您将其放置在 Intranet 上,这意味着您可能能够“托管”服务,例如数据库所有客户端都可以通过网络看到(和访问)的机器。在这种情况下,所有可能需要的是更改您可能位于应用程序配置文件中的任何连接字符串或路径。
回答by xyz
You could at least deploy it viathe web using ClickOnce
你至少可以部署它通过网络使用ClickOnce
ClickOnce deployment enables you to publish Windows-based applications to a Web server or network file share for simplified installation. Visual Studio provides full support for publishing and updating applications deployed with ClickOnce technology.
ClickOnce 部署使您能够将基于 Windows 的应用程序发布到 Web 服务器或网络文件共享以简化安装。Visual Studio 为发布和更新使用 ClickOnce 技术部署的应用程序提供全面支持。
http://msdn.microsoft.com/en-us/library/t71a733d(v=VS.90).aspx
http://msdn.microsoft.com/en-us/library/t71a733d(v=VS.90).aspx
回答by Danish Khan
I would recommend investing some time and modify the architecture to adopt SOA.
我建议投入一些时间并修改架构以采用SOA。
You should restructure your code and create a web servicethat would expose methods to the clients. These methods would take input from the client, perform operations and give back the data to display to the UI. You can pick your core business logic classes from the existing solution and reuse them as is. There might some amount of effort involved to separate out presentation logic from the business logic, but it would well worth the effort.
您应该重构您的代码并创建一个向客户端公开方法的Web 服务。这些方法将从客户端获取输入,执行操作并将数据返回给 UI 以显示。您可以从现有解决方案中选择核心业务逻辑类并按原样重用它们。将表示逻辑与业务逻辑分离可能需要付出一定的努力,但这非常值得。
Once you have your web service` hosted, you can use it with either a desktop application, or a web application. Of course, you would need to code the UI for Web application, but it would be much easlier than writing it from scratch.
托管 Web 服务后,您可以将其与桌面应用程序或 Web 应用程序一起使用。当然,您需要为 Web 应用程序编写 UI,但这比从头编写要容易得多。
回答by VdesmedT
You can deploy your application through the network using click-once and support updates trough it but I don't know any way to transform a winform application into a web-based application and I really doubt there is one considering the fundamental architecture changes between the two plaforms.
您可以使用单击一次通过网络部署您的应用程序并通过它支持更新,但我不知道有什么方法可以将 winform 应用程序转换为基于 Web 的应用程序,而且我真的怀疑是否有考虑过两个平台。
回答by Nighil
If you are using a database application in Windows then you can do one thing. You can deploy the database on the server, but you want to design a front-end application in ASP.NET for it, so that you can use your Windows application on the machine where you installed your application, and all others can also access it through the web.
如果您在 Windows 中使用数据库应用程序,那么您可以做一件事。您可以将数据库部署在服务器上,但是您想在 ASP.NET 中为它设计一个前端应用程序,这样您就可以在安装您的应用程序的机器上使用您的 Windows 应用程序,并且所有其他人也都可以访问它通过网络。