Problem when deploying ASP.Net Project in Centos

1

Good morning, I want to deploy a solution built on ASPnet, the development was done in WindowsSO / IIS, on a Centos Operating System using NginX Web server.

I'm using Centos-6.8, Nginx-1.10 and mono-4.6.1.5.

My nginx configuration file is:

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root /usr/share/nginx/html;
    #root /usr/share/nginx/html/Site;        

    location / {
        index index.aspx index.html index.htm index.aspx default.aspx Default.aspx Global.asax;
        fastcgi_index Global.asax;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
    }
   ...
}

In the file fastcgi_params I include:

 fastcgi_param  PATH_INFO          "";
 fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

And later I start the Mono service

fastcgi-mono-server4 /applications=/:/usr/share/nginx/html /socket=tcp:127.0.0.1:9000 &

By accessing link to test if it shows results.

When I invoke the solution through link is where I have problems, it shows the following message:

System.Web.HttpException
This type of page is not served.

Description: HTTP 403.The type of page you have requested is not served because it has been explicitly forbidden. The extension '.asax' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Details: Requested URL: /Site/Global.asax
Exception stack trace:
  at System.Web.HttpForbiddenHandler.ProcessRequest (System.Web.HttpContext context) [0x00073] in <d3ba84a338d241e2ab5397407351c9cd>:0 
  at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () [0x00dd7] in <d3ba84a338d241e2ab5397407351c9cd>:0 
  at System.Web.HttpApplication.Tick () [0x00000] in <d3ba84a338d241e2ab5397407351c9cd>:0 

Assign permissions to the nginx user on the Site folder that is where I have the solution, maybe I need to add some dependency in the Web.Config of the application, any ideas?

Thank you.

    
asked by jorgedison 22.11.2016 в 23:00
source

2 answers

0

Add new "location":

location /Site {
        index index.aspx index.html index.htm index.aspx default.aspx Default.aspx Global.asax;
        fastcgi_index Global.asax;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
    }
    
answered by 28.11.2016 в 20:10
0

I think the error occurs because you have set the file Global.asax as the home page and nginx is trying to execute it as if it were a page.

Probably solved by changing the configuration of the location block by:

location / {
    index index.aspx index.html index.htm index.aspx default.aspx Default.aspx;
    fastcgi_index Default.aspx;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
}

Update : if the project does not include a Default.aspx file (for example in a pure MVC project), in the fastcgi_index option you have to put / to refer to the root, and the index option could be removed.

The configuration would look like this:

location / {
    fastcgi_index /;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
}

And as he commented fredyfx in his answer, to access the application with link would have to add another location (in this case I think the value of fastcgi_index would be the same but I'm not sure)

location /Site {
    fastcgi_index /;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
}
    
answered by 28.11.2016 в 20:06