gigi81 / sharpfastcgi

C# fastcgi protocol implementation plus shome usage examples. A good example on how to self-host your web application without the need of iis or mono.
MIT License
32 stars 15 forks source link

Adding the ability to host Owin middlewares over FastCGI #9

Closed mikdav closed 6 years ago

mikdav commented 6 years ago

My organization had an Owin-based web service that unfortunately needed to call out to a legacy 3rd party component that is not thread safe and is completely outside of our control. Therefore, we could not host our web service in ASP.NET and needed something like FastCGI to provide process isolation for requests to prevent the memory corruption, etc, we were seeing when using the 3rd party component.

In order to not have to rewrite our entire web service and in order to leverage the many Owin middlewares out there for web frameworks and authentication, I decided to implement an Owin-compliant FastCGI server. Your project is probably the best written .NET FastCGI implementation--especially for IIS, which we use extensively.

The library in this pull request is now being used in production for us and has solved many of the threading woes we were seeing while hosting non-threadsafe components in an ASP.NET environment.

I look forward to your comments and suggestions.

gigi81 commented 6 years ago

Hi mikdav. Your PR is welcome. Anyway I'm on holiday for the next 10 days or so. I look forward to review it when I'm back!

mikdav commented 6 years ago

Awesome. Glad to see the merge. Would you be interested in me packaging the library up into nuget?

gigi81 commented 6 years ago

Thanks for the code. Looks good. I have not much time to test but I believe it works for owin. Just one question, can you review the following? context.Request.Scheme = nvp.Value.Equals("on", StringComparison.OrdinalIgnoreCase) ? "http" : "http"

Seems to me we are missing an "s" somewhere :-)

I was thinking about the NuGet package! For that, I can probably sort it out myself.

Anyway, I was also thinking this needs to be built for .net standard (while keeping the net framework build). Maybe you can help on that you feel like.

mikdav commented 6 years ago

Nice catch. Submitted a pull request with the fix. Surprisingly none of the middleware I use must care about the scheme key being correct because we don't use anything but https.

We don't really use .net standard at all, so it would be hard for me to justify spending work time on it. If I get a spare moment, I might be able to take a look at it.