我有一個本地化的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