I would like to implement a solution where I can pass data from my web page to a C# Application running on the same client PC that the browser is running on. After some research I found that using a TCP Listener or HTTP Listener, one can implement such a system - By making ajax requests/posts and then letting the listener catch these requests, then one can access the data in the request.
I then set out to write a small test application and hooray, it works! I used the code I found here(see answer) to implement a simple TCP listener, then opened my browser and navigated to http://localhost:8090/
and like I should, I saw the data that the listener responded with. This is great and all but now I have the problem that this listener needs to work along side my IIS server (or actually any service that will be hosting my wep app).
So I created a basic html page and added it as a site on IIS and tested it in the broweser to see if it works, so I simply navigated to http://localhost:8081/index.html
and my test page showed up. That's good - Then I changed the port that the listener is listening to from 8090
to 8081
, which is the port that IIS is using to host my site, and when I tried to start my listener with the new port I got the execption "An attempt was made to access a socket in a way forbidden by its access permissions
". Is IIS causing this problem, or will what I'm trying to do not work in any case because I'm using it in the wrong context.
Another thing I would like to do is rather use a HTTP Listener, but the only HTTP Listener examples I can find is individuals using it to create simple HTTP servers that actually serves the html and other resources to the browser (e.g. here). All I want is a HTTP Listener implementation of the code mentioned previously in the thread I linked.
In Summary: Like I mentioned in my introduction ...implement a solution where I can pass data from my web page to a C# Application...
, my end goal is to achieve communication to my C# app from my web page, doesn't matter if I use a HTTP or TCP Listener.