为什么如果我打电话:
http://localhost:55058/support/Faqs
我明白了:
http://localhost:55058/Products/Faqs/Faq
使用以下 RegisterRoutes 实现?我怎样才能得到:
http://localhost:55058/Support/Faqs/Faq
谢谢。
public class SupportController : Controller
{
public ActionResult FAQs()
{
return RedirectToAction("Faq", "Faqs");
}
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{filename}.html|js|css|gif|jpg|jpeg|png|swf");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.html/{*pathInfo}");
routes.MapRoute(
"Products", // Route name
"Products/{controller}/{action}", // URL with parameters
new { controller = "ProductName", action = "Index" } // Parameter defaults
);
routes.MapRoute(
"Support", // Route name
"Support/{controller}/{action}", // URL with parameters
new { controller = "Support", action = "Index" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults
);
}