GenHTTP Webserver
GenHTTP is a lightweight web server written in pure C# with few dependencies to 3rd-party libraries. The main purpose of this project is to serve small web applications and web services written in .NET, allowing developers to concentrate on the functionality rather than on handling the infrastructure.
As an example, the website of this project is hosted on a Raspberry Pi: genhttp.org
Features
- Setup new webservices or websites in a couple of minutes using project templates
- Optimized out of the box (e.g. by bundling resources or compressing results)
- Small memory and storage footprint
- Several themes available to be chosen from
- Grade A+ security level according to SSL Labs
Getting Started
After you added a reference to the GenHTTP.Core
nuget package, you can spawn a new server instance with just a few lines of code:
var content = Content.From(Resource.FromString("Hello World!"));
Host.Create()
.Handler(content)
.Run();
When you run this sample it can be accessed in the browser via http://localhost:8080. The documentation provides a step-by-step starting guide as well as additional information on how to implement webservices, websites, MVC style projects, or single page applications and how to host your application via Docker.
Building the Server
To build the server from source, clone this repository and run the playground project launcher for .NET 5:
git clone https://github.com/Kaliumhexacyanoferrat/GenHTTP.git
cd ./GenHTTP/Playground
dotnet run
This will build the playground project launcher for .NET Core with all the server dependencies and launch the server process on port 8080. You can access the playground in the browser via http://localhost:8080.
If you would like to contribute, see the contribution guidelines.
History
The web server was originally developed in 2008 to run on a netbook with an Intel Atom processor. Both IIS and Apache failed to render dynamic pages on such a slow CPU back then. The original project description can still be found on archive.org. In 2019, the source code has been moved to GitHub with the goal to rework the project to be able to run dockerized web applications written in C#.
Links
- Related to GenHTTP
- Reference projects
- Similar projects
Thanks
- .NET 5 for a nice platform