.NET HttpListener: when registering both HTTP & HTTPS I get "conflicts with an existing registration

Posted by Greg on Stack Overflow See other posts from Stack Overflow or by Greg
Published on 2010-04-12T00:15:15Z Indexed on 2010/04/12 0:23 UTC
Read the original article Hit count: 901

Filed under:
|

I'm trying to use .NET HttpListener in a C# project. When I register my prefix "http://*:8080/" it does not seem to work for HTTPS urls (i.e. doesn't pick them up). When I try the following code to register both the HTTP and HTTPS versions of the prefix however I get the error:

"Failed to listen on prefix 'https://:8080/' because it conflicts with an existing registration on the machine."*

How can I get my prefix working for both HTTP & 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

thanks

© Stack Overflow or respective owner

Related posts about .NET

Related posts about httplistener