如何在javascript中打开C#中的新表单? [英] How to open new form in C# from javascript?

查看:58
本文介绍了如何在javascript中打开C#中的新表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在尝试制作这样我就可以用HTML中的javascript打开C#表单。



我无法打开它,因为它需要STA线程。尝试在STA威胁上打开新表单的启动方法,但是一旦创建它就会关闭新创建的表单。



有人可以解释一下我怎么做我想做什么?



我尝试过的事情:



我尝试创建STA威胁并在那里打开新表单,但它会在出现时立即关闭。

Hello,

I'm trying to make so that I would be able to open C# form from javascript in HTML.

I can't open it, because it requires STA thread. Tried starting method which opens new form on STA threat, but then it closes newly created form as soon as it is created.

Could someone please explain me how I can do what I'm trying to do?

What I have tried:

I tried creating STA threat and opening new form there, but it closes as soon as it shows up.

推荐答案

你不能这样做。

Javascript被故意限制在它可以做的事情上:它不能做的主要事情之一就是在你的计算机上运行一个应用程序 - 任何应用程序。为什么?因为如果可以的话,恶意网站也是如此。因此出于安全原因,Javascript无法打开和应用程序。



Web环境中的C#代码在服务器上运行,而不是客户端:客户端甚至没有安装.NET,甚至能够安装它 - 它可能是一个连接互联网的冰箱,运行一个没有文件系统的基本浏览器!

Javascript总是运行在客户端,而不是服务器 - 即使它可能导致C#代码执行,表单也会显示在服务器上,距离用户所在地数千公里!
You can't do it.
Javascript is deliberately restricted in what it can do: and one of the major things it can't do is run an application - any application - on your computer. Why? Because if you could, so could malicious sites. So for security reasons, Javascript cannot open and applications.

And C# code in a web environment runs on the Server, not the Client: the client doesn't even have to have .NET installed, or even be capable of installing it - it could be an internet connected fridge running a basic browser without a file system at all!
Javascript always runs at the Client, not the Server - so even if it could cause C# code to execute, the form would be displayed at the Server, thousands of kilometers from where the user is sitting!


这篇关于如何在javascript中打开C#中的新表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆