The problem is as follows, all data is displayed in a table.

enter image description here

There is a VNC button, everything is fine and it works

<td>@Html.ActionLink("VNC", "VNC", new { id = items.id })</td> 

I have a controller

 public void VNC (int? id) { computer computer = db.computers.Find(id); Process.Start(@"C:\Program Files\RealVNC\VNC4\vncviewer.exe", computer.ipAdr); } 

But how to make sure that after clicking on the VNC button he did not try to open a new page by ID and leave the current page unchanged. Now happens as in the picture below.

enter image description here

  • one
    The vncviewer.exe process runs on the server , are you sure that this is what needs to be done? Now everything works for you, since the server is running on localhost, but as soon as you transfer it to another machine on the network, the vnc client will run on it, and not from the user with the browser. - kmv
  • By the way, how to make it run from the local machine? Thanks for noticing. If that I create a separate question on this topic. - shatoidil
  • Unfortunately, this is not so easy. For chromium, you have to write an extension, for IE, you need to use ActiveX. - kmv
  • one
    then you have to run the browser on the server (for example, via an rdp connection) - the advantages of the client-server architecture are lost. - kmv
  • one
    you can try using @Ajax.ActionLink - Grundy

1 answer 1

You can try this:

View page code:

 <td><a href="javascript:void(0)" onclick="VNC('@items.id')">VNC</a></td> 

Javascript:

 <script type="text/javascript"> function VNC(itemId){ $.ajax({ url: "@Url.Action("VNC","VNC")", type: "POST", data: { id: itemId }, dataType: 'json', cache: false, error: function(XMLHttpRequest, textStatus, errorThrown) { alert("Error" + errorThrown) }, success: function(data){ //Ничего не делать } }); } </script> 

Controller:

 [HttpPost] public ActionResult VNC (int? id) { computer computer = db.computers.Find(id); Process.Start(@"C:\Program Files\RealVNC\VNC4\vncviewer.exe", computer.ipAdr); return Json(true); }