简体   繁体   English

发布后CSS无法正常工作

[英]CSS Not Working After Published

I got errors ( Not Showing CSS ) in my project after deployed to server, it works fine in local .I found same questions like this and tried them all but still im unable to solved . 部署到服务器后,我的项目出现错误( 未显示CSS ),在本地工作正常。我发现了类似的问题,并尝试了所有问题,但仍然无法解决。

what i have tried : 我试过的

Style bundling not working after IIS deployment (MVC 4) IIS部署后样式绑定无法正常工作(MVC 4)

BundleConfig not rendered after publish in IIS 在IIS中发布后未呈现BundleConfig

ASP.NET MVC Bundle not rendering script files on staging server. ASP.NET MVC捆绑包未在登台服务器上呈现脚本文件。 It works on development server 它适用于开发服务器

ASP.NET MVC framework 4.5 CSS bundles does not work on the hosting ASP.NET MVC Framework 4.5 CSS捆绑软件不适用于主机

Why is my CSS bundling not working with a bin deployed MVC4 app? 为什么我的CSS绑定不能与已部署Bin的MVC4应用一起使用?

Error: 错误:

在此处输入图片说明

CSS Shows In Server Like This CSS这样显示在服务器中

<link href="/PMTEST/bundles/font-awesome/css?v=iW7LN24NnEoW62YKSq4wmEVP62Z-QPaYj8Wc4pAfkQA1" rel="stylesheet">
<link href="/PMTEST/bundles/animate/css?v=TS_TayB91ibtNEIEuFyRTY4MKruiSouKnZGvXM9wZzc1" rel="stylesheet">
<link href="/PMTEST/bundles/bootstrap/css?v=fGVgsGSw8MzJqPS1QdcxeRW2yrw4tez5BLZBchwK_HE1" rel="stylesheet">
<link href="/PMTEST/bundles/icon?v=Xt7dqD5fI6gBI3RBoPWSt1nfcmgT1f4bGcYcuT_dBno1" rel="stylesheet">

Bundle Config in my application 在我的应用程序中捆绑配置

 bundles.Add(new StyleBundle("~/bundles/font-awesome/css").Include(
                      "~/Vendor/fontawesome/css/font-awesome.min.css", new CssRewriteUrlTransform()));

In My Layout Page i used Bundle like 在我的布局页面中,我使用Bundle

   @Styles.Render("~/bundles/font-awesome/css")

Solved , just add 解决,只需添加

BundleTable.EnableOptimizations = false; BundleTable.EnableOptimizations = false;

in BoundalConfig BoundalConfig

For the fonts part you can use this in your web.config 对于字体部分,您可以在web.config使用它

<system.webServer>
  {...}
 <staticContent>
  <remove fileExtension=".woff" />
  <remove fileExtension=".woff2" />
  <remove fileExtension=".ttf" />
  <mimeMap fileExtension=".ttf" mimeType="application/font-sfnt" />
  <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
  <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>

And for the other bundle make sure the bundle reference path is not an actual file path, because if it is then IIS will handle it as a static file not MVC as a bundle. 对于其他包,请确保包引用路径不是实际的文件路径,因为如果是,则IIS会将其作为静态文件而不是MVC作为包来处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM