https://github.com/bpoe/dotnetcgi
How to implement CGI in .Net
https://github.com/bpoe/dotnetcgi
cgi common-gateway http
Last synced: 3 months ago
JSON representation
How to implement CGI in .Net
- Host: GitHub
- URL: https://github.com/bpoe/dotnetcgi
- Owner: Bpoe
- License: mit
- Created: 2023-05-13T00:39:18.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-24T05:15:40.000Z (almost 3 years ago)
- Last Synced: 2025-01-20T20:28:02.438Z (about 1 year ago)
- Topics: cgi, common-gateway, http
- Language: C#
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# .Net CGI
This code illustrates how to implement the Common Gateway Interface standard with C#. I created a simple CgiContext class that will build an
HttpRequestMessage from the environment variables passed by the web server. You can then use that to read the input and respond appropriately.
Why? Why not? This was mostly just educational to see how CGI works as an IPC method.
Sample
```dotnetcli
using Dotnet.Cgi;
using Newtonsoft.Json.Linq;
var app = new CgiApp();
app.Map(HttpMethod.Get, "/cgi/SampleCgiApp.exe/", async (context, parameters) =>
{
var responseContent = new JObject
{
["env"] = JObject.FromObject(Environment.GetEnvironmentVariables()),
["context"] = JObject.FromObject(context),
["requestBody"] = context.Request.Content?.ReadAsStringAsync().Result,
};
await context.Created(responseContent);
});
await app.Execute();
```