.NET的HttpListener:注册时,这两个HTTP和放大器; HTTPS我得到"用机和QUOT上的现有注册冲突; [英] .NET HttpListener: when registering both HTTP & HTTPS I get "conflicts with an existing registration on the machine"

查看:1731
本文介绍了.NET的HttpListener:注册时,这两个HTTP和放大器; HTTPS我得到"用机和QUOT上的现有注册冲突;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用.NET的HttpListener在C#项目。当我登记我的preFIX的http:// *:8080 /它似乎并没有工作HTTPS URL(即不接他们回家)。当我尝试以下code登记的preFIX HTTP和HTTPS版本,但是我得到的错误:

无法对preFIX听的https:// 的:8080 /',因为它与机器上的现有注册冲突*

我怎样才能让我的preFIX工作为HTTP和放大器; HTTPS?

 私人的HttpListener _listener;

    //创建prefixes
    VAR prefixes =新的名单,其中,串>();
    prefixes.Add(的http:// *:8080 /);
    prefixes.Add(https://开头*:8080 /);


    //创建的HttpListener
    _listener =新的HttpListener();
    的foreach(字符串$ P $在prefixes PFIX)
    {
        _listener prefixes.Add(preFIX)。
    }

    _listener.Start(); //< == ERROR HERE
 

编辑1 - 附加说明:

  • 该方案正在为PC应用程序发出HTTP(S)的本地代理呼叫。
  • 在使用,因此基于改变一个人的浏览器代理设置为指向长大代理服务器这个地方的家(如本地主机:8080)
  • 这意味着因此,(我认为)的的HttpListener具有监听HTTP和HTTPS此相同的本地端口(如8080)的交通。
  • 目的:试图找到一种方式,我的程序来听HTTP和HTTPS的同一端口上

感谢

解决方案
  

目标:试图找到一种方法,我   计划听取HTTP和   HTTPS的同一端口上。

您的不能使用的HttpListener做到这一点。您需要使用的TCPListener 并处理每个响应有条件视它是否是HTTP或HTTPS。

我是pretty的肯定,如果你使用一个的HttpListener用于HTTP 8080,另一个用于HTTPS 8443,你应该能够使你的浏览器使用yourproxy:8080 HTTP和yourproxy:8443用于HTTPS。 Firefox的肯定,让我们这样做。

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

EDIT 1 - Additional clarification:

  • The program is working as a local proxy for PC applications making HTTP(S) calls out.
  • Usage is therefore based on changing one's browser proxy settings to point to this local home grown proxy server (e.g. localhost:8080)
  • This implies therefore (I assume) that the HttpListener has to listen for both HTTP and HTTPS traffic on this same local port (e.g. 8080).
  • OBJECTIVE: Try to find a way for my program to listen to both HTTP and HTTPS on the same port.

thanks

解决方案

OBJECTIVE: Try to find a way for my program to listen to both HTTP and HTTPS on the same port.

You can't do this with HTTPListener. You'll need to use a TCPListener and handle each response conditionally depending on whether it is HTTP or HTTPS.

I'm pretty sure if you use one HTTPListener for HTTP 8080 and one for HTTPS 8443 you should be able to make your browser use yourproxy:8080 for HTTP and yourproxy:8443 for HTTPS. Firefox definitely let's you do this.

这篇关于.NET的HttpListener:注册时,这两个HTTP和放大器; HTTPS我得到&QUOT;用机和QUOT上的现有注册冲突;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆