# GenHTTP Webserver > Lightweight, embeddable HTTP web server written in C# with support for current standards such as Open API, JWT auth, Websockets and more. GenHTTP is an open source (MIT) web server framework for .NET, used as a library. Applications are built from handlers (such as webservices, static files or websockets) and concerns (such as authentication, CORS or compression), each a NuGet package of its own; GenHTTP.Full bundles them. ## Documentation - [Documentation](https://genhttp.org/documentation/): Simple tutorial to setup a web application using the GenHTTP framework. - [Content](https://genhttp.org/documentation/content/): Tutorials to write web applications (such as webservices or websites) using the GenHTTP server framework. - [Frameworks](https://genhttp.org/documentation/content/frameworks/): Frameworks are regular handlers that allow you to solve a problem (such as implementing web services) in a typical flavor or style, shaping the overall … - [Webservices](https://genhttp.org/documentation/content/frameworks/webservices/): Provide REST based web services in C# that can be consumed by clients to retrieve a JSON, YAML, or XML serialized result. - [Functional Handlers](https://genhttp.org/documentation/content/frameworks/functional/): Respond to HTTP requests in a functional manner with no boiler code. - [Controllers](https://genhttp.org/documentation/content/frameworks/controllers/): Lightweight framework to write web APIs using the controller pattern in C#. - [Websockets](https://genhttp.org/documentation/content/frameworks/websockets/): Create a simple websocket server in C# and dotnet - [MCP Tools](https://genhttp.org/documentation/content/frameworks/mcp/): Provide tools to AI agents such as Claude via the Model Context Protocol (MCP) in C#. - [Single Page Applications (SPA)](https://genhttp.org/documentation/content/frameworks/single-page-applications/): Simple way to host applications written with JS frameworks such as Vue.js, Angular or React. - [Static Websites](https://genhttp.org/documentation/content/frameworks/static-websites/): Simple way to host static websites with sitemap and robots.txt support - [Custom Frameworks](https://genhttp.org/documentation/content/frameworks/custom/): Shows how to use the underlying capabilities of GenHTTP to spin off a custom framework. - [Handlers](https://genhttp.org/documentation/content/handlers/): Low level handling of requests and generation of HTTP web server responses. - [API Browsing](https://genhttp.org/documentation/content/handlers/api-browsing/): Serves applications such as Swagger UI or Redoc to visualize an Open API definition hosted by the server. - [Content](https://genhttp.org/documentation/content/handlers/content/): Provides resources such as files or text - [Directory Browsing](https://genhttp.org/documentation/content/handlers/listing/): Simple web application to list the contents of a directory via HTTP. - [Files](https://genhttp.org/documentation/content/handlers/files/): Serve files from the file system, an assembly or another resource source, either individually or as a whole directory. - [Layouting](https://genhttp.org/documentation/content/handlers/layouting/): Easily break down your web application into logical sections of content. - [Liquid Pages](https://genhttp.org/documentation/content/handlers/liquid-pages/): Renders HTML pages from Liquid templates using a page model based approach. - [Load Balancer](https://genhttp.org/documentation/content/handlers/load-balancer/): Simple way to distribute load on specified HTTP webservers or different file systems. - [Pages](https://genhttp.org/documentation/content/handlers/pages/): Renders HTML pages from template files - [Redirects](https://genhttp.org/documentation/content/handlers/redirects/): Redirects requesting clients to another internal or external resource. - [Reverse Proxies](https://genhttp.org/documentation/content/handlers/reverse-proxy/): Server component to relay requests to an upstream server and return the result to requesting clients. - [Server Sent Events (SSE)](https://genhttp.org/documentation/content/handlers/server-sent-events/): Quickly setup a C# / .NET server to provide a simple Server Sent Events (SSE) stream (with examples). - [Virtual Hosts](https://genhttp.org/documentation/content/handlers/virtual-hosts/): Allows to handle requests depending on the host specified by the client (to serve multiple domains using a single server). - [Concerns](https://genhttp.org/documentation/content/concerns/): Add behavior to all handlers within a section of your web application. - [Authentication](https://genhttp.org/documentation/content/concerns/authentication/): Restrict the content provided by the server to authenticated users. - [Client Caching (Policy)](https://genhttp.org/documentation/content/concerns/client-caching-policy/): Instructs clients to cache responses generated by the server for some time. - [Client Caching (Validation)](https://genhttp.org/documentation/content/concerns/client-caching-validation/): Instructs clients to validate their cache when requesting resources to save bandwidth and resources. - [Compression](https://genhttp.org/documentation/content/concerns/compression/): Automatically compress responses generated by the webserver or add custom compression algorithms. - [CORS](https://genhttp.org/documentation/content/concerns/cors/): Automatically configure your webservices for Cross-Origin Resource Sharing. - [Decompression](https://genhttp.org/documentation/content/concerns/decompression/): Automatically decompress the content of incoming requests. - [Defaults](https://genhttp.org/documentation/content/concerns/defaults/): Automatically configures your web server for performance and security. - [Error Handling](https://genhttp.org/documentation/content/concerns/error-handling/): Generates custom HTTP responses for exceptions and missing content. - [Hardening](https://genhttp.org/documentation/content/concerns/hardening/): Automatically upgrade insecure requests, send a strict transport policy and prevent MIME type sniffing. - [Inspection](https://genhttp.org/documentation/content/concerns/inspection/): Inspect requests and responses as seen by the GenHTTP webserver - [Localization](https://genhttp.org/documentation/content/concerns/localization/): Automatic language negotiation to serve localized content. - [Open API](https://genhttp.org/documentation/content/concerns/open-api/): Dynamically generates an Open API v3 specification for a web service or controller - [Range Support](https://genhttp.org/documentation/content/concerns/range-support/): Enables partial responses if requested by the client, e.g. to resume downloads. - [Concepts](https://genhttp.org/documentation/content/concepts/): This page lists shared concepts or mechanisms that are used across various handlers. Concepts Request API Routing Method Definitions Code Generation Response … - [Request API](https://genhttp.org/documentation/content/concepts/request-api/): Describes the core request/response model of GenHTTP. - [Routing](https://genhttp.org/documentation/content/concepts/routing/): When the server receives a request from the client, it passes it to the root handler specified by your application. Depending on the requested path, this … - [Method Definitions](https://genhttp.org/documentation/content/concepts/definitions/): All API frameworks share a common base provided by the Reflection and Conversion modules which define some of the capabilities that can be used when defining an … - [Code Generation](https://genhttp.org/documentation/content/concepts/code-generation/): Enables code generation for GenHTTP web services for faster execution. - [Response Content](https://genhttp.org/documentation/content/concepts/response-content/): Describes the default I/O capabilities when working with response content in GenHTTP. - [Resources](https://genhttp.org/documentation/content/concepts/resources/): An abstraction layer over file system capabilities to allow binary content to be fetched from any data source - [Dependency Injection](https://genhttp.org/documentation/content/concepts/dependency-injection/): Enable dependency injection on the GenHTTP server. - [Testing](https://genhttp.org/documentation/testing/): Introduction to testing applications written by using the GenHTTP framework. - [Server](https://genhttp.org/documentation/server/): Tutorials to configure the GenHTTP webserver for best practices regarding security or performance. - [Engines](https://genhttp.org/documentation/server/engines/): Describes the webserver engines available to run GenHTTP projects with (such as Kestrel or Ioxide). - [Internal](https://genhttp.org/documentation/server/engines/internal/): The default HTTP engine implemented by the GenHTTP framework itself. - [Kestrel](https://genhttp.org/documentation/server/engines/kestrel/): Run GenHTTP applications on the Kestrel web server maintained by Microsoft. - [ioxide](https://genhttp.org/documentation/server/engines/ioxide/): An io_uring based HTTP engine for maximum throughput on Linux. - [Adapters](https://genhttp.org/documentation/server/adapters/): Use GenHTTP modules in other webserver frameworks such as ASP.NET. - [Logging](https://genhttp.org/documentation/server/logging/): Describes how to configure GenHTTP for logging. - [Endpoints and Ports](https://genhttp.org/documentation/server/endpoints/): Configure the GenHTTP webserver to listen on different ports or endpoints. - [Security](https://genhttp.org/documentation/server/security/): Security considerations and configuration options for GenHTTP applications. - [Hosting](https://genhttp.org/documentation/hosting/): Host web applications written in C# using the .NET docker images. - [Upgrade Guides](https://genhttp.org/documentation/upgrades/): Documentation on how to update to the most recent GenHTTP versions - [Upgrade to 10.x](https://genhttp.org/documentation/upgrades/v10/): Guide on how to upgrade to GenHTTP 10 from version 9.x - [Upgrade to 11.x](https://genhttp.org/documentation/upgrades/v11/): Guide on how to upgrade to GenHTTP 11 from version 10.x ## Samples Samples written in C#, each a complete Program.cs for a console app with the package GenHTTP.Full, with requests to try them. Most of them run live on this site. - [Webservices](https://genhttp.org/samples/webservices/): Implements a REST webservice via a handler class. - [Program.cs](https://genhttp.org/samples/webservices/Program.cs.txt) - [Functional](https://genhttp.org/samples/functional/): Uses delegates to implement a web service, similar to ASP.NET Core Minimal APIs. - [Program.cs](https://genhttp.org/samples/functional/Program.cs.txt) - [Controllers](https://genhttp.org/samples/controllers/): Uses controllers to implement a web service, similar to ASP.NET Core MVC. - [Program.cs](https://genhttp.org/samples/controllers/Program.cs.txt) - [Websockets](https://genhttp.org/samples/websockets/): A chat that pushes every message to all browsers in the same room. - [Program.cs](https://genhttp.org/samples/websockets/Program.cs.txt) - [MCP Tools](https://genhttp.org/samples/mcp/): Provides tools to AI agents such as Claude via the Model Context Protocol. - [Program.cs](https://genhttp.org/samples/mcp/Program.cs.txt) - [Static Websites](https://genhttp.org/samples/static-website/): Hosts a static website, with index.html support. - [Program.cs](https://genhttp.org/samples/static-website/Program.cs.txt) - [Single Page Applications](https://genhttp.org/samples/spa/): Hosts a single page application such as a React or Angular app. - [Program.cs](https://genhttp.org/samples/spa/Program.cs.txt) - [Custom Frameworks](https://genhttp.org/samples/custom-framework/): Builds a framework of your own on top of the reflection layer. (to run locally) - [Program.cs](https://genhttp.org/samples/custom-framework/Program.cs.txt) - [Layouting](https://genhttp.org/samples/layouting/): Routes requests to the handlers an application is made of. - [Program.cs](https://genhttp.org/samples/layouting/Program.cs.txt) - [Static Files](https://genhttp.org/samples/static-files/): Serves files from a directory or resource tree. - [Program.cs](https://genhttp.org/samples/static-files/Program.cs.txt) - [API Documentation](https://genhttp.org/samples/api-docs/): Generates an Open API definition and serves Swagger UI, Redoc and Scalar. - [Program.cs](https://genhttp.org/samples/api-docs/Program.cs.txt) - [Server Sent Events](https://genhttp.org/samples/sse/): A live ticker that receives prices pushed by the server. - [Program.cs](https://genhttp.org/samples/sse/Program.cs.txt) - [Pages](https://genhttp.org/samples/pages/): Renders HTML pages from templates on the server. - [Program.cs](https://genhttp.org/samples/pages/Program.cs.txt) - [Virtual Hosting](https://genhttp.org/samples/virtual-hosting/): Hosts multiple websites, one per domain, on a single server. (to run locally) - [Program.cs](https://genhttp.org/samples/virtual-hosting/Program.cs.txt) - [Load Balancing](https://genhttp.org/samples/load-balancing/): Distributes requests over workers and mirrors, with a canary deployment. (to run locally) - [Program.cs](https://genhttp.org/samples/load-balancing/Program.cs.txt) - [Authentication](https://genhttp.org/samples/authentication/): Secures an API with API keys, roles and data per user. - [Program.cs](https://genhttp.org/samples/authentication/Program.cs.txt) - [CORS](https://genhttp.org/samples/cors/): Allows a frontend on another origin to call the API from the browser. - [Program.cs](https://genhttp.org/samples/cors/Program.cs.txt) - [Error Handling](https://genhttp.org/samples/errors/): JSON errors for the API, HTML error pages for the website, custom mapping. - [Program.cs](https://genhttp.org/samples/errors/Program.cs.txt) - [Localization](https://genhttp.org/samples/localization/): Responds in the language preferred by the user. (to run locally) - [Program.cs](https://genhttp.org/samples/localization/Program.cs.txt) - [Inspection](https://genhttp.org/samples/inspection/): Shows what the server received and responded, to debug clients. - [Program.cs](https://genhttp.org/samples/inspection/Program.cs.txt) - [Dependency Injection](https://genhttp.org/samples/dependency-injection/): Lets the framework construct services and pass their dependencies. (to run locally) - [Program.cs](https://genhttp.org/samples/dependency-injection/Program.cs.txt) - [File Share](https://genhttp.org/samples/file-share/): Password protected directory listing with resumable downloads. - [Program.cs](https://genhttp.org/samples/file-share/Program.cs.txt) - [Legacy Migration](https://genhttp.org/samples/legacy-migration/): Replaces a legacy app step by step with a reverse proxy, redirects and new endpoints. (to run locally) - [Program.cs](https://genhttp.org/samples/legacy-migration/Program.cs.txt) ## Optional - [Source code](https://github.com/Kaliumhexacyanoferrat/GenHTTP): the repository of GenHTTP on GitHub - [NuGet](https://www.nuget.org/packages/GenHTTP.Full/): GenHTTP.Full, the package with all modules