We want to open rdp machine in our mvc view page in c#.
Loading
We want to open rdp machine in our mvc view page in c#.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mohamed Azarudeen ZRank #297 · 8.5K reputationPosted May 11, 2023, 3:30 AM EDT
To open an RDP (Remote Desktop Protocol) machine in an MVC (Model-View-Controller) view page using C#, you can use the Process.Start() method to launch the RDP client application and pass the IP address or hostname of the remote machine as a parameter.
public ActionResult ConnectToRemoteMachine(string ipAddress) { // Path to the RDP client application string rdpClientPath = @"C:\Windows\System32\mstsc.exe"; // Command-line arguments to launch RDP client with the specified IP address string arguments = "/v:" + ipAddress; // Launch the RDP client process Process.Start(rdpClientPath, arguments); // Return a view or redirect to another page return View(); }raj rajRank #5,629 · 292 reputationPosted May 12, 2023, 8:32 AM EDT
Hi Our requirement to open rdp machine window in mvc page not outside it should display the rdp machine inside view mvc
Tuhin PaulRank #7 · 71.9K reputationPosted May 12, 2023, 11:10 PM EDT
Steps on how to open an RDP machine in your MVC view page in C#:
1. Add the following namespaces to your view page:
using System.Diagnostics; using System.Runtime.InteropServices;2. In your view page, create a function that will open the RDP machine. The function should have the following signature:
public static void OpenRDPMachine(string machineName, string userName, string password)3. In the function, use the following code to open the RDP machine:
// Create a Process object for the Remote Desktop Connection (RDC) executable. Process rdpProcess = new Process(); // Set the RDC executable's path. rdpProcess.StartInfo.FileName = @"C:\Windows\System32\mstsc.exe"; // Set the RDC executable's arguments. rdpProcess.StartInfo.Arguments = "/v:" + machineName + " /u:" + userName + " /p:" + password; // Start the RDC executable. rdpProcess.Start();4. Call the OpenRDPMachine() function from your view page. For example, you could use the following code:
@using (Html.BeginForm("OpenRDPMachine", "Home")) { }5. In your controller action, handle the form submission and call the OpenRDPMachine() function. For example, you could use the following code:
public ActionResult OpenRDPMachine(string machineName, string userName, string password) { // Open the RDP machine. OpenRDPMachine(machineName, userName, password); // Return a success message. return Content("The RDP machine has been opened."); }Tuhin PaulRank #7 · 71.9K reputationPosted May 12, 2023, 11:11 PM EDT
You can improve the code by:
raj rajRank #5,629 · 292 reputationPosted May 16, 2023, 5:26 AM EDT
Requirement is to open rdp machine in browser tab
raj rajRank #5,629 · 292 reputationPosted May 16, 2023, 5:33 AM EDT
@Tuhin Paul,
we want to open rdp machine in browser tab