简体   繁体   English

如何让客户端计算机上的程序从ASP.NET页面运行?

[英]How can I get a program on a client machine to run from an ASP.NET page?

I have an app that I'm trying to run on an intranet. 我有一个应用程序,我试图在Intranet上运行。 On my machine it worked great (famous last words) but when I put it up to the server, it didn't work. 在我的机器上它工作得很好(着名的遗言)但是当我把它放到服务器上时,它没有用。 As soon as I saw the "the system cannot find the specified file" error, I figured it had to be something with trying to run a program that's on a client machine. 当我看到“系统找不到指定文件”错误时,我认为它必须是尝试运行客户端计算机上的程序。

Yes, it would be a security nightmare if any app in a browser could run an executable on a client machine. 是的,如果浏览器中的任何应用程序可以在客户端计算机上运行可执行文件,那将是一场安全噩梦。 Is this any different for intranet? 内联网有什么不同吗? The few computers it would run on all have the same version of IE and .NET that it will run on, and they all have the required .exe to run. 它将运行的几台计算机都具有相同版本的IE和.NET,它们将运行,并且它们都具有运行所需的.exe。

Here's an overview of the project: 以下是该项目的概述:

  • An employee and a participant walk into a room containing a computer. 员工和参与者走进包含计算机的房间。
  • The employee opens my web app and looks up the person's ID (this part works) 员工打开我的网络应用程序并查找该人的ID(此部分有效)
  • Clicking on "record" should perform a hidden launch of an already-installed program, which begins recording. 单击“记录”应执行已安装程序的隐藏启动,该程序开始记录。
  • When finished, the employee clicks finish (or the app times out) and the file is saved. 完成后,员工单击完成(或应用程序超时)并保存文件。
  • File gets uploaded to server. 文件上传到服务器。
  • The employees lack technical experience, so my objective is to pretty much have a website for them to go to where there is little more than a box to get the participant ID and two giant "RECORD" and "STOP" buttons 员工缺乏技术经验,所以我的目标是为他们提供一个网站,只需一个盒子即可获得参与者ID和两个巨大的“RECORD”和“STOP”按钮

Can anyone help me out on how to do this (or at least let me know it's not feasible)? 任何人都可以帮我解决如何做到这一点(或者至少让我知道这是不可行的)?

一个想法:您可以注册协议处理程序以使用所需参数启动您的应用程序。

There are a couple of ways to do this. 有几种方法可以做到这一点。 One doesn't violate security (much). 一个人不违反安全(很多)。

You can download a file with a particular file type. 您可以下载具有特定文件类型的文件。 That file type can be associated to the client program, so after clicking "ok" to download the file, the client program would launch. 该文件类型可以与客户端程序关联,因此在单击“确定”下载文件后,客户端程序将启动。 The downloaded file may or may not contain some data like the id of some object. 下载的文件可能包含也可能不包含某些数据,如某些对象的ID。

The alternative would be to resort to ActiveX, which does have security implications. 另一种方法是使用ActiveX,它确实具有安全隐患。

If you put your site in the IE Trusted or Intranet zone, the following Javascript will work just fine. 如果您将您的网站放在IE Trusted或Intranet区域,以下Javascript将正常工作。 I use this one internally to link our PC support DB search to our remote screen control software: 我在内部使用这个将我们的PC支持数据库搜索链接到我们的远程屏幕控制软件:

<script type="text/javascript" language="javascript">
    function runDameWare(strHostname, blControl) {
        var objShell = new ActiveXObject("Wscript.Shell");
        var strCommand = "C:\\Program Files\\Dameware\\dwrcc.exe -c: -h: -m:";
        strCommand += strHostname;
        if (blControl) {
            strCommand += " -v:";
        }
        objShell.Exec(strCommand);
    }
</script>

My understanding is that uploading the results of your work in the local program to the web server can be accomplished using the HttpWebRequest class, as shown in this article: 我的理解是,可以使用HttpWebRequest类将本地程序中的工作结果上传到Web服务器,如本文所示:

http://forums.asp.net/p/1482778/3464854.aspx http://forums.asp.net/p/1482778/3464854.aspx


Edit: This is how I call the above function. 编辑:这是我如何调用上述功能。 Basically I'm just rendering a plain <a> element with the onclick attribute. 基本上我只是用onclick属性渲染一个普通的<a>元素。 There's probably a cleaner way to do it, but it works: 可能有一种更简洁的方法,但它有效:

Markup: 标记:

<asp:TemplateField>
    <ItemTemplate>
        <%# RenderDameWareLinks(Eval("ResourceName"))%>
    </ItemTemplate>
</asp:TemplateField>

Code: 码:

Protected Function RenderDameWareLinks(ByVal strHostname As String) As String
    Dim strFullLink As String = String.Empty
    Dim strViewLink As String = String.Empty
    strFullLink = "<a onclick=""runDameWare('" & strHostname & "', false);"">"
    strFullLink &= "<img alt=""Connect using DameWare"" src=""Image/dameware1.gif"" style=""padding: 2px;"" />"
    strFullLink &= "</a><br/>"
    strViewLink = "<a onclick=""runDameWare('" & strHostname & "', true);"">"
    strViewLink &= "<img alt=""Connect (View Only) using DameWare"" src=""Image/dameware2.gif"" style=""padding: 2px;"" />"
    strViewLink &= "</a>"
    Return strFullLink & strViewLink
End Function

由于机器已经需要安装这个“隐藏”程序,为什么不只是编写一个本机应用程序并安装它并让员工运行而不是你的Web应用程序?

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

相关问题 如何在 ASP.net 中获取客户端计算机用户登录? - How can I get client machine user login in ASP.net? 如何获取客户端计算机的窗口原理ID(asp.net) - How to get window principle id of client machine (asp.net) 如何在 ASP.NET / C# 中获取客户端计算机名称? - How to get Client Machine Name in ASP.NET / C#? 如何在asp.net中获取客户端机器的临时路径? - How to get temporary path of client machine in asp.net? 我如何从asp.net页运行任何win.exe? - How can i run any win.exe from asp.net page? 如何从 ASP.NET 中的文件路径获取文件并将文件返回给客户端 - How can I get file from filepath in ASP.NET and return the file to the client 如何从ASP.Net Web应用程序读取/写入客户端计算机的串行端口 - How can read/write serial port of client machine from ASP.Net Web application 如何从ASP.NET网站(而不是Web应用程序)中的用户控件获取父页面 - How can I get the parent page from a User Control in an ASP.NET Website (not Web Application) 如何从ASP.net MVC程序中获取普通c#程序中的JSON数据? - How do I get JSON data in a plain c# program from a ASP.net MVC program? 我如何在asp.net页面上知道客户端与服务器在同一网络中? - How can I know the client is in the same network of the server on an asp.net page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM