0

I have a simple ASP.NET WebForms app that I created in Windows and copied over to a Linux server (Ubuntu 14.04) that is running fastcgi-mono-server4 and nginx. The app runs fine on windows, but when running on mono it fails to get the WebResource.axd?d=... script because of a 404 error. As such, all postbacks fail because WebForm_OnSubmit() is undefined.

If I remove my ScriptManager and all validators from the page, it runs fine on mono because WebResource.axd is no longer required. However, I don't want to do that because I want to use AJAX.

I tried the solution in this post, but it had no effect. I also tried adding that tag to the system.webServer/handlers section, but that did not work either.

I also tried following this article to use AJAX without a ScriptManager. It worked fine on windows, but failed in mono by giving me a 404 error for all of my web service requests.

So my question is: why do I get a 404 error when trying to download WebResource.axd, and how do I fix it? Is there some mono or nginx configuration that I need to fix?

EDIT: here is my nginx configuration:

server {
    listen       80;
    server_name  www.example.com;
    access_log   /var/log/nginx/example.access.log  main;
    location / {
        root         /var/www/www.example.com;
        index        Default.aspx;
        try_files $uri $uri/ /Default.aspx;
        fastcgi_index Default.aspx;
        fastcgi_pass 127.0.0.1:9000;
        include /etc/nginx/fastcgi_params;
        fastcgi_param PATH_INFO "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

1 Answers1

0

I figured out the answer using This article. Basically, I needed to add a special location for the .axd files in my nginx configuration. My final configuration is below; it also allows page methods to work.

server {
    listen       80;
    server_name  www.example.com;
    access_log   /var/log/nginx/www.example.access.log;
    location ~\.(aspx|axd)(.*) {
        include fastcgi_params;
        fastcgi_split_path_info ^(.+.aspx)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_index Default.aspx;
        fastcgi_pass 127.0.0.1:9000;
    }
    location / {
        root         /var/www/www.example.com;
        index        Default.aspx;
        try_files $uri $uri/ $uri.aspx /Default.aspx;
        fastcgi_index Default.aspx;
        fastcgi_pass 127.0.0.1:9000;
        include /etc/nginx/fastcgi_params;
        fastcgi_param PATH_INFO "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}