Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在.NET内核中,HttpListener的模拟是什么_C#_Asp.net Core_.net Core_Visual Studio 2017_Asp.net Core 2.0 - Fatal编程技术网

C# 在.NET内核中,HttpListener的模拟是什么

C# 在.NET内核中,HttpListener的模拟是什么,c#,asp.net-core,.net-core,visual-studio-2017,asp.net-core-2.0,C#,Asp.net Core,.net Core,Visual Studio 2017,Asp.net Core 2.0,我正在将应用程序从.NET4移植到.NETCore,但找不到HttpListener类的模拟 Error CS0246 The type or namespace name 'HttpListener' could not be found (are you missing a using directive or an assembly reference?) 更新1 private readonly HttpListener _httpListener;

我正在将应用程序从.NET4移植到.NETCore,但找不到HttpListener类的模拟

Error   CS0246  The type or namespace name 'HttpListener' could not be found (are you missing a using directive or an assembly reference?)  
更新1

        private readonly HttpListener _httpListener;

            if (!HttpListener.IsSupported)
        {
            throw new NotSupportedException(
                "The Http Server cannot run on this operating system.");
        }

        _httpListener = new HttpListener();
        _httpListener.Prefixes.Add(prefix);
        _sessionSettings = settings;

如评论中所述,
WebListener
(在
Microsoft.Net.Http.Server
NuGet包中)是最接近的替代品,但具有不同的API。或者,还有Kestrel HTTP服务器,它最好从ASP.NET核心堆栈中使用,但可以单独使用(但这很难设置)


如果您正在进行移植,我建议您等到.NET Core 2.0,它有一个跨平台的工作机制,不需要您完全更改代码。

在.NET Core 2.0中,我们没有这个问题(感谢Martin Ullrich),所以现在我们需要安装在可以使用.NET Core 2.0的地方

但默认情况下(目前最低要求)没有.NET Core 2.0,我们需要在VS 2017安装后安装


再次感谢Martin Ullrich-这真是太棒了,5月10日(离我提问的时间只有3天了).NET Core 2.0-我现在有了它

WebListener?github上也有一些简单的库(WebListener和github.com/robertsundstrom/HttpListener)都没有一些属性,而且由于不兼容,您有没有任何示例,在收到带有
acceptsync
的请求后,如何使用
WebListener
发送响应?