我目前有一个调用StyleResolver动作的Style控制器,它允许我在将要使用的css主题之间切换。
if (contractState == "FL" || contractState == "TX")
{
Response.ContentType = "text/css";
return Razor.Parse(System.IO.File.ReadAllText(Server.MapPath("~/Content/genesis-theme-flat/jquery-ui-1.10.4.custom.css")));
}
else if (contractState == "AZ" || contractState == "CA" ||
contractState == "GA" || contractState == "MO" ||
contractState == "NM" || contractState == "SC" ||
contractState == "UT")
{
Response.ContentType = "text/css";
return Razor.Parse(System.IO.File.ReadAllText(Server.MapPath("~/Content/nowcom-theme-flat/jquery-ui-1.10.2.custom.css")));
}
问题现在是这两个文件中所有与图像相关的css,导致文件路径问题
.ui-widget-content {
border: 1px solid #ececec;
background: #ffffff url("images/ui-bg_flat_0_ffffff_40x100.png") 50% 50% repeat-x;
color: #333;
}
.ui-widget-header {
border: 1px solid #ececec;
background: #ececec url("images/ui-bg_highlight-soft_0_ececec_1x100.png") 50% 50% repeat-x;
color: #960000;
font-weight: bold;
}
这些图像位于这些文件夹中。
结果路径:
http://localhost:50402/Style/images/ui-bg_flat_0_ffffff_40x100.png 404 (Not Found)
http://localhost:50402/Style/images/ui-bg_highlight-soft_0_ececec_1x100.png 404 (Not Found)
似乎在调用Razor.Parse后,URL未正确指向" Content / of-theme / images" 文件夹,而是包含调用Style控制器。如何修复显示的路径以解决图像的404问题?
答案 0 :(得分:0)
通过以这种方式强制url路径来修复。
URL(/content/genesis-theme-flat/images/ui-bg_glass_0_960000_1x400.png)