標籤:logs tor cto proc include wrapper table direct settings
項目是嵌套在主站的一個子網站,結果用CssRewriteUrlTransform來將相對目錄路徑改成相對網站根目錄路徑的時候發現少了虛擬目錄的路徑。最終解決方案:
/// <summary> /// 實現支援虛擬目錄的路徑轉換 /// </summary> public class CssRewriteUrlTransformWrapper : IItemTransform { public string Process(string includedVirtualPath, string input) { return new CssRewriteUrlTransform().Process("~" + VirtualPathUtility.ToAbsolute(includedVirtualPath), input); } }
調用的方式:
bundles.Add(new StyleBundle("~/Content/css").Include("~/media/css/default.css", "~/media/css/uniform.default.css", "~/Content/bootstrapValidator.css", //"~/Content/icheckv2/skins/green.css", "~/Scripts/sweetAlert2/sweetalert2.min.css", ).Include("~/Content/icheckv2/skins/green.css",new CssRewriteUrlTransformWrapper()) ); BundleTable.EnableOptimizations = true;// ConfigurationManager.AppSettings["Environment"]!="Dev";
參考地址:CssRewriteUrlTransform with or without virtual directory
MVC Bundle產生的css路徑問題