Low level ASP.NET Core example web server with NativeAOT. ~2.5MB size
An example of using the ASP.NET Core servers for a .NET web application without any of the rest of the framework (e.g. Hosting, middleware etc). So you can create your own distinct opinionated framework.
Mostly its an example to derive from.
src\Ben.Http
contains and sets up the server; it is Kestrel by default, but any server deriving from 'IServer' will also work (e.g. HttpSys
, IIS
, etc)
HttpServer.cs
contains the server that is newed up; currently set to various defaults/
HttpContext.cs
contains the Request/Response context, but this can be changed to be whatever set of properties you want to expose; in whatever way you want to expose them. Generally you get the information from the server by asking the IFeatureCollection
for them and they are in the namespace Microsoft.AspNetCore.Http.Features
HttpApplication.cs
is the application that deals with processing the requests. This creates and disposes of the HttpContext
setting its features; and in this example Task ProcessRequestAsync(HttpContext context)
is abstract
so an application can derive from this class and implement that one method; and the bolierplate of setting up the Request/Response context is handled for them.
Windows
Visual Studio 2022, including Desktop development with C++ workload.
Ubuntu (20.04+)
sudo apt-get install libicu-dev cmake
dotnet build
-
Windows
dotnet publish -r win-x64 -c Release dotnet publish -r win-arm64 -c Release
-
Linux
dotnet publish -r linux-x64 -c Release dotnet publish -r linux-arm64 -c Release
-
MacOS
dotnet publish -r osx-x64 -c Release dotnet publish -r osx-arm64 -c Release
You should take a look at these related projects: