Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am wondering how can I make a desktop application running on Windows receive HTTP requests from WebApp?

That is the desired workflow:
WebApp -> Desktop App -> Process Data

The question is: How can WebApp send request to Desktop App?

What I have tried:

One of the ideas that I have is to install and run an Apache server on the Windows PC.
After the server is installed, the WebApp to send requests to this specific PC.
Using PHP to manage the requests and forward the request to the desktop application.
Posted
Updated 21-Nov-19 2:07am

Try something like HttpListener

HttpListener Class (System.Net) | Microsoft Docs[^]

You can have it listen on port 80 and it will act as a web server but if any web server is running on the client machine you won't be able to use port 80, so you would have to use a different port like 8001 or whatever and the client would sent requests to

http://yourip:8001/
 
Share this answer
 
v2
You can also use a (self hosted) SignalR application, see: Tutorial: SignalR Self-Host | Microsoft Docs[^]
 
Share this answer
 
The way I would implement this is to break this down into several modules, not to far off from your idea of using Apache.

Service(s).
You are going to need to have a Web Service to accept the HTTP requests.

You could also use a Windows Service, and move the data processing to it, and the Web Service would act like a buffer between the web clients and the data processing. This is the way I would go as I feel it adds more control.

Desktop App. This would be a front-end only, and would communicate with the Service when things needed to be done.
If you only use a web service, the desktop app would need to communicate via HTTP

Data Flows
If you use the 2 service method (Windows & Web) then you could have 2 paths
Local App <==> Windows Service
Remote Client <==> Web Service <==> Windows Service

If you only do the web service, then you would only have the one path:
Client (local app OR remote) <==> Web Service


I personally would work the local side first; breaking the data processing out and putting it into a Windows Service, and creating an interface to communicate back and forth between the front-end and data processing.
When you do the Web Service, you could then bring in the desktop's half of the communication part to "translate" the web requests into service calls

With the two-service method, if the web service was down you would still have local access via the app.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900