FastCGI for .NET

Build Status

This is an implementation of FastCGI for .NET, written in C#. It implements the parts of the protocol that are necessary to build a simple web application using .NET.

This means that you can write web applications in C# that serve dynamic content.

This project is hosted on Github.

Basic usage

The most common usage scenario is to use this library together with a web server like Apache and nginx. The web server will serve static content and forward HTTP requests for dynamic content to your application.

Have a look at the FastCGI.FCGIApplication class for usage examples and more information.

This code example shows how to create a FastCGI application and receive requests:

// Create a new FCGIApplication, will accept FastCGI requests
var app = new FCGIApplication();

// Handle requests by responding with a 'Hello World' message
app.OnRequestReceived += (sender, request) =>
    var responseString =
          "HTTP/1.1 200 OK\n"
        + "Content-Type:text/html\n"
        + "\n"
        + "Hello World!";


// Start listening on port 19000

API Reference

You can find the API reference here: API reference


The library is available via NuGet. To install, type this in the package manager console:

Install-Package FastCGI

Or, using the command-line interface:

nuget install FastCGI

For more information, refer to the NuGet documentation.

License and contributing

This software is distributed under the terms of the MIT license. You can use it for your own projects for free under the conditions specified in LICENSE.txt. The full source code is available on Github.

If you have questions, feel free to contact me. Visit for my contact details.

If you think you found a bug, you can open an Issue on Github. If you make changes to this library, I would be happy about a pull request.

Web server configuration

For nginx, use fastcgi_pass to pass requests to your FastCGI application:

location / {
    fastcgi_pass; # Pass all requests to port 19000 via FastCGI.
    include fastcgi_params; # (Optional): Set several FastCGI parameters like the remote IP, the URI, and other useful metadata.

In the example above, fastcgi_params is a file that defines FastCGI parameters. It is included in most nginx default configurations and contains lines like these:

fastcgi_param   QUERY_STRING       $query_string;
fastcgi_param   REMOTE_ADDR        $remote_addr;

For more details, refer to your web server documentation for configuration details: