简体   繁体   English

在ASP.net网页中嵌入Windows窗体

[英]Embedding Windows Form in an ASP.net webpage

I have written a Chat application using C#. 我已经使用C#编写了一个聊天应用程序。 The project is a separate Windows forms application. 该项目是一个单独的Windows窗体应用程序。 Now i do not want to write the entire code in the project where i am creating a webpage using asp.net. 现在,我不想在使用asp.net创建网页的项目中编写整个代码。 I want to do something like this: 我想做这样的事情:

  1. The user opens the webpage, 用户打开网页,
  2. Registers, 寄存器,
  3. On the next page there would a button [Toolbox button] which the users clicks and that would initialize my form and hence the chat application. 在下一页上,会有一个[工具箱按钮]按钮,用户单击该按钮,它将初始化我的表单,从而初始化聊天应用程序。

How can i achieve this? 我怎样才能做到这一点?

That is completely impossible (except for IE-only). 这是完全不可能的(仅IE除外)。

WinForms and web development are completely different. WinForms和Web开发完全不同。

You could deploy your WinForm application as a Click-Once .Net deployment, and link the users to this after registering. 您可以将WinForm应用程序部署为Click-Once .Net部署,并在注册后将用户链接到此。 However, you'd need to ensure your app works in this type of environment, and you'd begin limiting your user base because it would require they have the same version of the .Net framework and the ability to run a click-once application. 但是,您需要确保您的应用程序在这种类型的环境中运行,并且开始限制用户群,因为这将要求他们具有相同版本的.Net框架,并且必须能够运行一次单击应用程序。

What you are asking is to have the browser download your application and run it locally on the machine. 您要的是让浏览器下载您的应用程序并在计算机上本地运行。 You have to make sure that the user's machine is compatible ie that it is running Windows with the correct version of the .Net runtime (for non-Windows machine, it has to have the correct version of Mono and the application should be compatible with it). 您必须确保用户的计算机兼容,即运行的Windows具有正确版本的.Net运行时(对于非Windows计算机,它必须具有正确的Mono版本,并且应用程序应与之兼容)。

Most browsers will prevent you from directly downloading an application and running it. 大多数浏览器会阻止您直接下载并运行应用程序。 You will have to give users explicit instructions on how to save and run the app. 您将必须向用户提供有关如何保存和运行该应用程序的明确说明。 For Windows machines, you can use ClickOnce to automatically install and run the application. 对于Windows计算机,可以使用ClickOnce自动安装和运行该应用程序。

Another option worth considering is converting your app to Silverlight. 另一个值得考虑的选择是将您的应用程序转换为Silverlight。 It provides a lot of the interactivity of a desktop application while being hosted on a web page and while using C#. 当托管在网页上和使用C#时,它提供了许多桌面应用程序的交互性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM