【发布时间】:2011-02-14 16:35:15
【问题描述】:
在我的 ASP.NET MVC3 应用程序中,我尝试模拟“routes.IgnoreRoute("...")” 我创建 CustomMvcRouteHandler:
public class CustomMvcRouteHandler: MvcRouteHandler
{
protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
{
// do something
....
return base.GetHttpHandler(requestContext);
}
}
在我的 Global.asax.cs 文件中:
protected void Application_Start()
{
// ............
RegisterRoutes(RouteTable.Routes);
// ............
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("elmah.axd");
//routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
).RouteHandler = new CustomMvcRouteHandler();
}
我该怎么做?
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-mvc-2 asp.net-mvc-3 asp.net-mvc-routing