Quantcast
Channel: General
Viewing all articles
Browse latest Browse all 7363

mstsc.exe present in .cshtml file is not working when application is hosted on IIS

$
0
0

Hi -

I have a mstsc code in .cshtml below:

@{

    var Name = "";

    var Employee_ID = "";

    var Team = "";

    var Laptop = "";

    var Desktop1 = "";

    var DesktopMonitor1 = "";

    var Desktop2 = "";

    var DesktopMonitor2 = "";

    var Monitor = "";

    var Workstation = "";

    var Workstation2 = "";

    var movieId = "";

 

    var Operatingsystem = "";

    var Computername = "";

    var IP = "";

    var Operatingsystem2 = "";

    var Computername2 = "";

    var IP2 = "";

 

 

 

    if (Request.QueryString["ID"] != null)

        {

            movieId = Request.QueryString["ID"];

            var db = Database.Open("Labmanager");

            var dbCommand = "SELECT * FROM AssetDBtest where IP=@0";

            var row = db.QuerySingle(dbCommand, movieId);

 

            if (row != null)

            {

                Name = row.Name;

                Employee_ID = row.Employee_ID;

                Team = row.Team;

                Laptop = row.Laptop;

                Monitor = row.Monitor;

                Desktop1 = row.Desktop1;

                DesktopMonitor1 = row.DesktopMonitor1;

                Workstation = row.Workstation;

                Desktop2 = row.Desktop2;

                DesktopMonitor2 = row.DesktopMonitor2;

                Workstation2 = row.Workstation2;

                Operatingsystem = row.Operatingsystem;

                Computername = row.Computername;

                IP = row.IP;

                Operatingsystem2= row.Operatingsystem2;

                Computername2 = row.Computername2;

                IP2 = row.IP2;

 

          

            }

   

   

 

 

 

    if (Request.QueryString["ID"].Equals(IP))

    {

 

 

        System.Diagnostics.Process rdcProcess = new System.Diagnostics.Process();

        string executable = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.exe");

        if (executable != null)

        {

            rdcProcess.StartInfo.FileName = executable;

            rdcProcess.StartInfo.Arguments = "/v " + IP;  // ip or name of computer to connect

            rdcProcess.Start();

        }

 

    }

    }  }

Here we are picking the IP from DB and making connection through RDC. This works fine when running through Visual Studio.

But when the same Application is hosted on IIS, The RDC connection is not established.

Can someone please help on this.


Viewing all articles
Browse latest Browse all 7363


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>