I am trying to use the .NET HttpListener in a C # project. When I register my prefix "http: // *: 8080 /", it does not work for HTTPS URLs (i.e. Does not pick them up). When I try to use the following code to register both HTTP and HTTPS versions of the prefix, however, I get an error:
"Could not listen to the prefix" https: //: 8080 / "because it conflicts with existing registration on the computer."
How can I get the prefix for HTTP and HTTPS?
private HttpListener _listener; // Create prefixes var prefixes = new List<string>(); prefixes.Add("http://*:8080/"); prefixes.Add("https://*:8080/"); // Create HttpListener _listener = new HttpListener(); foreach (string prefix in prefixes) { _listener.Prefixes.Add(prefix); } _listener.Start(); // <== ERROR HERE
EDIT 1 - Additional clarification:
- The program acts as a local proxy server for PC applications that make HTTP (S) calls.
- Therefore, the use is based on changing the settings of the browser proxy server to point to this local home proxy server (for example, localhost: 8080).
- This means, therefore (I believe), that the HttpListener should listen for both HTTP and HTTPS traffic on the same local port (for example, 8080).
- PURPOSE: try to find a way for my program to listen on both HTTP and HTTPS on the same port .
thanks
Greg
source share