我的MVC 4网站使用Bundle.Config类添加CSS文件
bundles.Add(new StyleBundle("~/Content/Styles").Include(
"~/Content/css/website.css",
"~/Content/css/banner.css"));
在我的localhost上,当我查看源代码时,HTML文件呈现为
<link href="/Content/css/website.css" rel="stylesheet"/>
<link href="/Content/css/banner.css" rel="stylesheet"/>
我现在已经部署了我的网站,但源代码只提供了1行
<link href="/Content/Styles?v=fxCdHAOgPDvcROxkMfEwGQggO9uCfzckN3PaN8BOIzI1" rel="stylesheet"/>
奇怪的是,大多数CSS仍然显示(但图像不显示)。
我认为问题不在于我的web.config文件,因为本地和实时共享相同的文件。
我的问题是,如何删除此行为并让实时服务器以与本地主机相同的方式呈现HTML?
答案 0 :(得分:2)
捆绑将您的css缩小为一个文件,为了让您的图片工作,您需要设置捆绑,以便~/Content/Styles
相对于您的实际css,因此将其设置为~/Content/css/Styles
如果您不希望在已部署的网站上进行捆绑,请查看this post
答案 1 :(得分:2)
public class LessTransform:IBundleTransform { public void Process(BundleContext context,BundleResponse response) { response.Content = Less.Parse(response.Content); //这里的断点 response.ContentType =&#34; text / css&#34 ;; } }