使用带有MVC3的servicestack,无法正常工作

时间:2012-02-17 12:47:37

标签: asp.net-mvc-3 servicestack

我刚刚创建了一个新的MVC3项目并通过nuget安装了servicestack mvc。然后我根据README.txt将它添加到Global.asax.cs中的RegisterRoutes:

routes.IgnoreRoute("api/{*pathInfo}"); 
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" }); //Prevent exceptions for favicon

Servicestack出现此错误:

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

除非我在Global.asax.cs中注释掉它:

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

如何让MVC3和Servicestack工作。我正在使用VS2010,IIS7。

1 个答案:

答案 0 :(得分:0)

尝试执行以下两个步骤:

1.在Application_Start中禁用MVC WebApi注册。

//WebApiConfig.Register(GlobalConfiguration.Configuration);

2.Ignore MVC路线如'api /'

routes.IgnoreRoute("api/{*pathInfo}");