This is a FastCGI client implementation for .NET. It allows applications to serve content through a standard web server like Apache or Nginx with less overhead than an HTTP proxy solution.

Development time 2015
Development duration 1 Month
Technologies C#
License MIT
Team size Single developer

The FastCGI protocol is designed for communication between a web server and a web application. It is commonly used for PHP or Python web applications. However, when I needed it, there was no usable implementation for .NET available. This library fills that gap. It is MIT licensed, tested and documented.

The library provides both, a simple event interface that allows responding to requests with a few lines of code, and a more complex interface that allows managing the FastCGI communication in all details.

This code sample creates a very simple web application that responds with a hello world message to every request:

// 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) => {
    request.WriteResponseASCII("HTTP/1.1 200 OK\nContent-Type:text/html\n\nHello World!");
    request.Close();
};

// Start listening on port 19000
app.Run(19000);

You can then connect your web server to the FastCGI port your app is listening on. In Nginx, that would look like this:

location / {
  include fastcgi_params;
  fastcgi_pass   localhost:19000;
}

See more of my projects