单声道MVC 2家庭路线不起作用

Ale*_*lex 8 mono routing nginx asp.net-mvc-2

我正在尝试将ASP .NET MVC 2应用程序转换为在nginx/mono 2.8上运行.到目前为止它似乎工作得很好,除了当路径为空时默认路由不起作用.我将所有请求代理到fastcgi服务器,并且我得到了一个ASP .NET 404找不到的页面.

即这不起作用

http://mysite.com
Run Code Online (Sandbox Code Playgroud)

但这样做

http://mysite.com/home
Run Code Online (Sandbox Code Playgroud)

我的Global.asax.cs文件看起来像这样

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);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑:我的设置更多信息.我正在运行OS X 10.6,如​​果这有任何区别.MVC项目中任何区域的默认路由也存在同样的问题.

And*_*bal 5

我实际遇到了同样的问题并且完全错误地解决了它(至少在我的情况下)...

在mono项目网站的nginx演练中,它说要在你的nginx.conf文件中输入这些行:

index index.html index.htm default.aspx Default.aspx;
fastcgi_index Default.aspx;
Run Code Online (Sandbox Code Playgroud)

好吧,我在两个虚拟机上以完全相同的方式设置它(或者我认为).问题是,一个VM有它的根URL工作而一个没有.结果是我忘记了VM上"索引"行上的分号,因此'fastcgi_index'行被解释为'index'行的一部分.

所以在没有工作的VM上,我删除了那个分号.你猜怎么着?有效.然后我添加了分号并完全删除了'fastcgi_index'行,它仍然有效.因此,基于这些轶事证据和一些猜测工作,我会说'fastcgi_index'行不应该包含在MVC应用程序中.好吧,至少MVC 3,我没有测试过任何其他东西.