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

Hosting ASP.NET MVC? #14

Open naasking opened 4 years ago

naasking commented 4 years ago

Your introduction suggests it would be possible to host an ASP.NET MVC site, but it's not at all clear how to do this. Online the consensus seems to be that MVC depends too heavily on System.Web which is bound to the IIS pipeline, and so can't be hosted in OWIN.

Can you provide some clarification on this and/or the steps to enable MVC using OWIN in your FastCGI library?

gigi81 commented 4 years ago

First of all, .net framework asp.net or dotnet core asp.net? Because they are two completely different things.

For dotnet core asp.net, I have a branch but it will need some work. Also, I'm not sure how much sense it will make as you can already self host it without the need of fastcgi.

For dotnet framework asp.net it makes no difference from a web forms webiste as provided in the nginx example. Simply drop your website in the "Root" folder as in the example. The only thing is that you will need to change the fastcgi configuration of the example to not just load aspx pages but any url (like for example /home/contact), something like this should work for nginx:

        location / {
            root           html;
        fastcgi_keep_conn on;
            fastcgi_pass   backend;
            fastcgi_index  Default.aspx;

            include        fastcgi_params;
        }

I will keep this issue open do add also an mvc example