Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Kestrel without ASP.NET core

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?

like image 826
Hristo Kolev Avatar asked Jun 08 '18 20:06

Hristo Kolev


People also ask

What is ASP NET Core Kestrel?

Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's included by default in ASP.NET Core project templates. Kestrel is supported on all platforms and versions that .NET Core supports.

Can I run Kestrel on a web server?

Now, even if you are not working cross-platform, you can run ASP.NET on a web server straight from the command line. Since Kestrel is not a fully-featured web server, you should run it behind IIS or NGINX. It was designed to make ASP.NET as fast as possible but is limited in its ability to manage security and serve static files.

What is project name in Kestrel?

In the case of the Kestrel web server, the process name that is used to host and run the ASP.NET Core application is the project name. As of now, we are using visual studio to run the ASP.NET Core application.

What are the benefits of using Kestrel?

Benefits of Kestrel. Kestrel has support on all platforms and versions supported by .NET Core. Furthermore, it is included by default in ASP.NET Core new project templates and can provide better request processing performance. When you create a new project in Visual Studio, your project is automatically configured to run in Kestrel.


1 Answers

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.

like image 105
Morteza Zabihi Avatar answered Sep 22 '22 15:09

Morteza Zabihi