4
我正在尋找在我的Content文件夾中動態生成一些 CSS文件。打開RouteExistingFiles時的注意事項
目前,這個文件夾有一個忽略路徑(routes.IgnoreRoute("Content/{*wildcard}");
),我希望保持這種狀態,因爲我不需要/希望大部分內容文件夾進入MVC請求生命週期。
例子:
routes.MapRoute(
"DynamicCSS",
"Content/Css/Dynamic/{guid}.css",
new { controller = "Site", action = "GenerateCSS" },
new { guid = @"^([0-9a-fA-F]){8}([0-9a-fA-F]){4}([0-9a-fA-F]){4}([0-9a-fA-F]){4}([0-9a-fA-F]){12}$" }
);
//If the file has already been generated, IIS should just return the file, saving a request in MVC.
routes.RouteExistingFiles = true; //was formerly false
//Ignore routes
routes.IgnoreRoute("Content/{*wildcard}");
我對此設置了幾個問題/顧慮:
- 將這項工作? ASP.NET MVC中的路由很懶,但我不知道是否首先檢查忽略路由。這種使用形式沒有文檔(我Google搜索!)。
- 打開
RouteExistingFiles
時是否有任何安全隱患需要考慮?我不希望IIS直接引用它們來拾取我的Model/Views文件夾。
非常感謝您的任何建議。
編輯:
經過進一步研究,我已經在我的第一個問題找到了一個article。