0

I need help with this.

I need to perform some action on the client computer, such as reading the smart card from the card reader. To do this, I created a desktop application (WPF) that runs in the Windows notification area. On the other side, I have an asp.net application from which I need to call an action on the client machine. It is necessary to call the action from the frontend, but it may be useful to call it from the backend in the future. Could you please help me with a solution for this?

Thank you :)

I'm thinking of running a self-hosted web server in a WPF application that will receive API calls from the frontend of my web application (javascript). Maybe something like a kestrel?

EDIT:

For anyone else dealing with a similar problem. I found this great blog post that describes more options for implementing this type of web-app communication.

https://textslashplain.com/2019/08/28/browser-architecture-web-to-app-communication-overview/

  • Does this answer your question? [how to start up a desktop application in client side](https://stackoverflow.com/q/6265717/328193) – David Mar 22 '23 at 20:40
  • A self-hosted web server is an interesting approach. The browser may or may not play nice with cross-origin requests to localhost, it would be worth testing in a variety of browsers. Though if you have a locally installed application then there's likely a lot you *can* do. – David Mar 22 '23 at 20:43
  • @David it likely work just fine, even more *fine* than OP wants (or claim) to :). Since most people can't write/configure code to be secure (even ignoring those who do it on purpose) such local publicly accessible webserver is perfect way to expose extra information from local machine to everyone interested on the internet. Granted if that is done on small scale to non-interesting group of targets it's probably ok, but finding such group is hard... So the best to go with this approach when you have explicitly nefarious goals or non-internet-facing tightly-controlled network. – Alexei Levenkov Mar 22 '23 at 20:50
  • GitHub website can launch GitHub Desktop, which is clearly an example for you to follow. The linked thread contains enough hints on how to implement that kind of protocol. – Lex Li Mar 22 '23 at 21:08
  • You could simply have your desktop app poll the server repeatedly to ask the server if it wants info. If the server says yes, then your desktop app can post the details to the server. However, polling can be inefficient, particularly if done rapidly (depends on the level of responsiveness you need). Another option would be to maintain a live connection to the server, perhaps by web sockets, particularly [SignalR](https://dotnet.microsoft.com/en-us/apps/aspnet/signalr). Of course, leaving an active connection on has its own overhead associated with it. – mason Mar 23 '23 at 01:19
  • Hi, I have read all the comments and thank you very much for your advice. I'll definitely look into SignalR, gRPC and queue messaging. --- For anyone else dealing with a similar problem. I found this great blog post that describes more options for implementing this type of web-app communication. https://textslashplain.com/2019/08/28/browser-architecture-web-to-app-communication-overview/ – Martin Novotný Mar 23 '23 at 20:05

0 Answers0