【发布时间】:2015-02-18 07:30:58
【问题描述】:
我的网址:http:///Home/addorders //工作正常
需要这样打:http:///addorders
我在 RouteConfig 中添加了我的自定义路由:但它对我不起作用
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
"addorders", // Route name
"addorders/{id}/{str}", // URL with parameters
new { controller = "Home", action = "addorders", id = UrlParameter.Optional, str = UrlParameter.Optional },// Parameter defaults
new[] { "AngularJsExample.Controllers" }
);
}
}
【问题讨论】:
-
你需要把你的指定路由放在默认路由之前
-
谢谢它的工作... @stephen
标签: c# asp.net asp.net-mvc routing