I'm porting application from .NET 4 to .NET Core and can't find analog for HttpListener class
Error CS0246 The type or namespace name 'HttpListener' could not be found (are you missing a using directive or an assembly reference?)
Update1
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;
As mentioned in the comments, WebListener
(in the Microsoft.Net.Http.Server
NuGet package) is the closest replacement, but has a different API. Alternatively, there is the Kestrel HTTP server, which is best consumed from the ASP.NET Core stack but can be used alone (but that is difficult to set up).
If you are porting, I'd suggest to wait until .NET Core 2.0, which has an API compatible HttpListener
that works cross-platform and doesn't require you to completely change the code.