使用 jquery 打开 RDP 连接窗口 - 客户端

Man*_*aju 2 javascript c# asp.net-mvc jquery

有没有办法使用 jquery(客户端)打开 RDP 连接窗口?

我的jquery代码如下,

$(function () {
        $(".RDPLink1").live('click', function () {
            var IPAddress = $(this).attr('id');  // ip or name of computer to connect

            $.ajax({
                type: 'post',
                cache: false,
                data: { strIPAddress: IPAddress },
                url: '<%=Url.Action("OpenRDPWindow","Home") %>',
                success: function (data) {                        
                }
            });
        });
Run Code Online (Sandbox Code Playgroud)

我调用Home控制器方法,名称是OpenRDPWindow,比如

    public void OpenRDPWindow(string strIPAddress)
    {            
        Process objProcess = new Process();
        string exe = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.exe");
        if (exe != null)
        {               
            objProcess.StartInfo.FileName = exe;
            objProcess.StartInfo.Arguments = "/v " + strIPAddress;   // ip or name of computer to connect
            objProcess.Start();
        }            
    }
Run Code Online (Sandbox Code Playgroud)
  • 其实我的需要是,当用户点击我页面中的href链接时,我们需要打开基于IP地址的RDP窗口...

  • 在我使用 VS2010 的系统中,它工作正常并且它
    基于 IP 地址打开 RDP窗口,因为我将服务器端(C#)中的代码
    写入我的系统......

  • 在 IIS 中部署项目后,然后用户单击 href 链接,RDP(mstsc.exe)正在服务器机器(我部署我的
    应用程序)中运行。

  • 但是我需要在用户机器(客户端)中打开 RDP 窗口...

我如何使用 jquery 或 javascript 解决这个问题?(或)有没有其他方法可以解决这个问题?

提前致谢....@@@

Man*_*aju 5

我按照下面给出的步骤来解决这个问题,

1)Jquery代码是

$(function () {
    $(".RDPLink1").live('click', function () {
        var IPAddress = $(this).attr('id');  // ip or name of computer to connect
        window.location.href="http://path/home/OpenRDP?address="+IPAddress ;            
    });
});
Run Code Online (Sandbox Code Playgroud)

2)我创建了一个新的 .aspx 页面并在 GET 方法(页面加载)中编写下面给出的服务器端(C#)代码来解决这个问题

[HttpGet]
public ActionResult OpenRDP()
{
        string address = Request.QueryString["address"];
        Response.ContentType = "application/octet-stream";
        Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}.rdp", address));
        Response.Output.Write(string.Format(@"
screen mode id:i:2
session bpp:i:32
compression:i:1
keyboardhook:i:2
displayconnectionbar:i:1
disable wallpaper:i:1
disable full window drag:i:1
allow desktop composition:i:0
allow font smoothing:i:0
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:{0}
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:2
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
drivestoredirect:s:E:;
use multimon:i:0
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:2
redirectdirectx:i:1
use redirection server name:i:0", address));

        Response.End();
        return View();
}
Run Code Online (Sandbox Code Playgroud)

它将从客户端的浏览器下载选项打开 RDP 窗口....

所以,这是这个问题的一种解决方案......