2

I know the answer is almost certainly no, but I was wondering if you could run code from a server on a user's computer (with their permission).

I have an ASP.NET application running on a remote IIS. What I want the application to do is to be able to access a PCI board on the user's computer and do some work with it. To my knowledge, I cannot do that with just JS running in the browser.

I understand that this would be a huge security vulnerability to the user, but they could Opt-in or Opt-out as necessary.

The other option is to have the application already on the user's computer and ran by the server when necessary, but I just wanted to know if this was even possible.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Gunnarhawk
  • 437
  • 3
  • 12
  • You either run code on the server, in the user's browser (JavaScript or WASM c#), or give the user an exe. – gunr2171 Mar 25 '21 at 16:54
  • If you want a server to control an application installed on user's machines, you need to have a communication channel between the app and the server. Have your application run as a Windows Service or on Windows startup, and open a TCP connection or whatever, over which the server can send commands to the client and receive data in return. Or have the app poll the server over HTTP for work. – CodeCaster Mar 25 '21 at 16:54
  • You should take a look at `SignalR` or `gRPC`. Both of these things could control methods execution in a restricted and secure area. – dgzargo Mar 25 '21 at 16:57

1 Answers1

1

It is surprisingly simple, assuming you have access to the user's PC and can install something on his machine (and that's why it's no security issue). You must register a custom URI scheme, which means that you associate a certain program to a protocol taht you specify yourself.

See here

A protocol is something like http. You can create your own protocol like "myxyz" and use URLs like myxyz://blah/blah in your web pages.

Whenever an URL with your protocol is called, the program you associated with the protocol will start. The rest of the URL will be passed to your program as a command line parameter.

Heinz Kessler
  • 1,610
  • 11
  • 24
  • *Whenever an URL with your protocol is called*. Would this be called by the user's browser, say redirecting them to this url when they click a button? – Gunnarhawk Mar 25 '21 at 17:17
  • OP wants to trigger the executable to read some data on demand. In your scenario, the user has to be in their browser and click a link. – CodeCaster Mar 25 '21 at 17:24