我有一个本地化的httphandler,它运行在我的ASP.Net MVC2 Content文件夹(它正在编译./文件中的/ Content/css)的上下文中。对于这个特殊的组请求我的默认路由看起来是这样的:这个IgnoreRoute调用为什么匹配这些请求?
context.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
context.MapRoute(
"Area_default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new { controller = new VirtualDirectoryConstraint("VDirectory1") },
new string[] { "Namespace.One.MVC" }
);
(顺便说一句 - 我不认为这是相关的,但以防万一 - 在VirtualDirectoryConstraint拒绝匹配这条航线上,如果要求不是来自传入的应用程序路径/虚拟目录)
由于没有ContentController类,因此调用http://server.net/VDirectory1/Content/css/LessCompiler.axd
失败。一切都很好。
当我添加
context.Routes.IgnoreRoute("{Content}/{*pathInfo}");
调用成功,但后续调用
http://server.net/VDirectory1/Localization/ClientScript/en-US.js
和
http://server.net/VDirectory1/Authorization/ClientScript
失败。综观菲尔哈克的RouteDebugger工具,这些调用的匹配内容IgnoreRoute路线:
True {Content}/{*pathInfo} (null) (null) (null)
,因此不会被分别路由到LocalizationController和AuthorizationController。
很明显,我误解了应该如何使用IgnoreRoute以及为什么特定的IgnoreRoute匹配这些请求。我错过了什么?
这似乎确定问题,谢谢! – cori