14

I want to use Kestrel HTTP Server to do HTTP things unrelated to the ASP.NET abstraction. I don't want to install any of the ASP.NET packages just Kestrel and use Request/Response model to write a fast/performant HTTP application.

In the old days this was done with HttpListener, but since everything now runs on Linux I can't use HTTP.sys.

Every Kestrel example shows how to use it with ASP.NET Core using the WebHost thingy.

I just want to run a console application that opens a port and gives me HTTP requests.

I'm almost 100% sure that this is possible. How I'm I supposed to do it?

Hristo Kolev
  • 1,486
  • 1
  • 16
  • 33
  • I believe Kestrel is written in .net core, so you'd be hard pressed to not use those packages. – Erik Funkenbusch Jun 08 '18 at 20:47
  • 1
    Use https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.core.kestrelserver?view=aspnetcore-2.1 and https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.internal.hostingapplication.-ctor?view=aspnetcore-2.1#Microsoft_AspNetCore_Hosting_Internal_HostingApplication__ctor_Microsoft_AspNetCore_Http_RequestDelegate_Microsoft_Extensions_Logging_ILogger_System_Diagnostics_DiagnosticListener_Microsoft_AspNetCore_Http_IHttpContextFactory_ – SLaks Jun 08 '18 at 20:53
  • 1
    Kestrel runs a series of middleware, so you just need to learn how to customize which middleware components to load, and remove all ASP.NET Core related ones, leaving only what matters to you, such as static file middleware and URL rewrite middleware. – Lex Li Jun 09 '18 at 02:12

1 Answers1

4

Kestrel has many dependencies to Asp.Net packages in both Transport and Http layer. even if you want to use just Kestrel.Transport and implement your own HttpServer, you need the packages like Microsoft.AspNetCore.Hosting in Kestrel.Transport.Abstraction and Kestrel.Transport.Socket libraries. So if you want to remove these dependencies, you need a full customize on all Kestrel class libraries.

Morteza Zabihi
  • 2,884
  • 1
  • 20
  • 20