abenci
abenci

Reputation: 8651

How to communicate between ASPX and WinForms

How can I send commands to a WinForms application from an ASPX web page? We have already explored executing the WinForms application with different command line parameters but wanted something more smart.

Thanks.

Upvotes: 2

Views: 796

Answers (3)

Devin Burke
Devin Burke

Reputation: 13820

Create a web server within your application that listens for HTTP GET and/or POST commands and acts appropriately. Then use AJAX to send request, i.e., http://localhost/myapp/?command=print&file=teletubies.jpg

Your web server, which is just a program that listens on port 80 and sends responses according to the very simple HTTP protocol, within your application then parses the requested URL and decides that it should print the file teletubies.jpg based on the query string in the URL.

Upvotes: 1

Jeff Sheldon
Jeff Sheldon

Reputation: 2104

I don't know of any way this can be done due to security. I know I wouldn't want people to be able to access the running applications on MY machine from their web app.

Upvotes: 0

Joel Coehoorn
Joel Coehoorn

Reputation: 416149

Web pages (whether running asp.net or a competing platform) are always reactive. They receive commands (requests) and respond. They are not proactive, and don't send commands. This is how the core technology on which the internet is built works.

This means is you want an asp.net page to send a message to a client app, the only way to do it is for the client app to frequently poll the page, possibly using System.Net.WebClient.

Upvotes: 0

Related Questions