Windows/.NET | Linux/Mono |
---|---|
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 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.
If you have questions, feel free to contact me. Visit lukas-boersma.com 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.
The project documentation is hosted here: fastcgi-for-net.readthedocs.org
The user guide is mostly the same as this readme. Here is a direct link to the 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.
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!";
request.WriteResponseASCII(responseString);
request.Close();
};
// Start listening on port 19000
app.Run(19000);
For nginx, use fastcgi_pass
to pass requests to your FastCGI application:
location / {
fastcgi_pass 127.0.0.1:19000; # Pass all requests to port 19000 via FastCGI.
include fastcgi_params; # (Optional): Set several FastCGI parameters like the remote IP and other metadata.
}
For more details, refer to your web server documentation for configuration details: