Is there a .NET FastCGI library?

2019-06-23 14:50发布

I'm developing a small server that is supposed to interface via http. As I want it to be usable with different mature http servers, I have chosen FastCGI as the common interface.

Now I can't find a (free) .NET library that implements the FCGI interface and does all the hard work for me. Do you know one?

标签: .net fastcgi
5条回答
聊天终结者
2楼-- · 2019-06-23 15:20

Yes, there are many libaries like SharpCGI and FCGIDotNet, but they all implement the server-side of the protocol. I still need to find code to talk to an existing FastCGI server, it's just the opposite of what all these libraries do (allthough the code for it is for 90% the same).

查看更多
Melony?
3楼-- · 2019-06-23 15:25

I recently implemented such a library in F#: SharpCGI

Also completely usable from C#.

The problem Kragen describes is solved with some Win32 hackery, exploiting .NET internals. However, you don't have to use that if you configure your web server to use a designated port for FastCGI instead.

查看更多
太酷不给撩
4楼-- · 2019-06-23 15:29

I've come here after all this time to say that I've created a FastCGI library written in C# that might be useful to future readers. It is not heavily documented (FastCgi is a pretty simple standard, so I don't see why it would be) but I think it is documented well enough to be used by others.
Currently, it exposes an API both for application servers as for web servers, although some features might still be missing. You should still check it out.
I haven't touched it much lately but it does work really well for me (I still use it).

You can download it via NuGet or at my GitHub. It is called FastCgiNet.

查看更多
虎瘦雄心在
5楼-- · 2019-06-23 15:31

Not that I am aware of (I'm also looking)

One of the difficulties lies in the fact that FastCGI seems to require that you pass a handle to a listener socket to a child process in place of the normal StdIn handle - something which the standard .Net classes (Process, Socket etc...) don't allow. This means implementing a FastCGI library in .Net ultimately requires re-implementing the Process and Socket classes using P/Invoke calls to native Windows functions.

查看更多
做个烂人
6楼-- · 2019-06-23 15:36

See Mono.WebServer.FastCGI at
https://github.com/mono/xsp/tree/master/src

There's also a FastCGI CLIENT here:
http://sourceforge.net/projects/fcgidotnet/

And the FastCGI specification is here:
http://www.fastcgi.com/devkit/doc/fcgi-spec.html

You can find a OWIN compliant implementation here:
https://github.com/mzabani/Fos

Additionally, these libraries are also interesting:


HyperFastCGI:
https://github.com/xplicit/HyperFastCgi

or
https://github.com/gigi81/sharpfastcgi

or #cgi
https://github.com/wmeyer/SharpCGI

If you need more examples on FastCGI CLIENTs, you can have a look at this go library

https://github.com/tomasen/fcgi_client

查看更多
登录 后发表回答