【发布时间】:2015-06-25 07:21:27
【问题描述】:
我目前有一个样式控制器,它调用 StyleResolver 操作,它让我可以在将要使用的 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/name-of-theme/images" 文件夹,而是包含调用样式控制器。如何修复显示的路径以解决图像的 404 问题?
【问题讨论】:
标签: html css asp.net-mvc razor