views:

111

answers:

1

I'm trying to convert an ASP .NET MVC 2 app to run on nginx/mono 2.8. So far it seems to work quite well except that the default route doesn't work when the path is empty. I am proxying all requests through to the fastcgi server and I get served up with an ASP .NET 404 not found page.

i.e. This doesn't work

http://mysite.com

But this does

http://mysite.com/home

My Global.asax.cs file looks like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MyProject
{
    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // Default route
            routes.MapRoute(
                "Default",                      // Route name
                "{controller}/{action}/{id}",   // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
                new string[] {"MyProject.Controllers"}
            );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes);
        }
    }
}

EDIT: Some more info on my setup. I am running OS X 10.6 if that makes any difference. Also the same problem exists for the default route of any areas in the MVC project.

+1  A: 

Did you follow the nginx configuration from this page?: http://www.mono-project.com/FastCGI_Nginx

My guess would be the default document is getting in the way.

Chris
Yep I have exactly that setup. And it still doesn't work :(
Alex
This is totally stupid, but what if you add a beginning slash to the route url: "/{controller}/{action}/{id}". Only thing I can think of considering @Alex's suggestions technically works, and your Area default routes also don't work (meaning your default document shouldn't be a problem)
Chris