C# 将RouteConfig文件从ASP.Net MVC 4迁移到5

C# 将RouteConfig文件从ASP.Net MVC 4迁移到5,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,以下RouteConfig在ASP.NET MVC 4中工作: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapPageRoute(

以下RouteConfig在ASP.NET MVC 4中工作:

 public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapPageRoute(
                "Cuisine",
                "cuisine/{name}",
                new {controller = "Cuisine",action = "Search", name =""});

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
在ASP.NETMVC5中,语句

 routes.MapPageRoute(
                "Cuisine",
                "cuisine/{name}",
                new {controller = "Cuisine",action = "Search", name =""});
生成错误

Error   CS1503  Argument 3: cannot convert from '<anonymous type: string controller, string action, string name>' to 'string'   
错误CS1503参数3:无法从“”转换为“字符串”
显然,
MapRoute
的签名已更改

如何将代码迁移到ASP.NETMVC5

试试这个

routes.MapRoute(
            name: "Cuisine",
            url: "cuisine/{name}",
            defaults: new {controller = "Cuisine",action = "Search", name = UrlParameter.Optional});

拥有
name=”“
真的没有意义。我假设您想要
name=UrlParameter。可选的
模式应该匹配/courine/French、courine/意大利语等格式中的任何内容。
路由。MapPageRoute
用于WebForms。您应该使用
routes.MapRoute