Skip to content

Low level ASP.NET Web server with NativeAOT

License

Notifications You must be signed in to change notification settings

lixinyang123/Ben.Http.NativeAOT

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ben.Http.NativeAOT

NuGet version (Ben.Http)

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.

Using Ben.Http

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.

Building

Prerequisites

Windows

Visual Studio 2022, including Desktop development with C++ workload.

Ubuntu (20.04+)

sudo apt-get install libicu-dev cmake

Build

dotnet build

Publish with NativeAOT

  • 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

Related Projects

You should take a look at these related projects:

About

Low level ASP.NET Web server with NativeAOT

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%