0
ASP .Net自定义路由不起作用。ASP .Net自定义路由不起作用
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 = "Account", action = "LogOn", id = UrlParameter.Optional } // Parameter defaults
);
//custom route
routes.MapRoute(
"Admin",
"Admin/{addressID}",// controller name with parameter value only(exclude parameter name)
new { controller = "Admin", action = "address" }
new { addressID = @"\d+" }
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
public ActionResult address(int addressID = 0)
{
//code and redirection
}
在这里,我想隐藏一切从URL如果可能的话...像我想隐藏操作名称和参数名称,如果可能的值... 建议我可能的方式做到这一点
像我想要URL这样的(优先的基础上)
1.http://本地主机:ABCD /管理员
或 2.http://本地主机:ABCD /管理/地址
或 3.http: // localhost:abcd/Admin/1
或 4.http:// localhost:abcd/Admin/address/1
http://stackoverflow.com/a/1479505/1679410 – dakait 2013-03-07 07:21:47