2

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 .

what i have tried :

Style bundling not working after IIS deployment (MVC 4)

BundleConfig not rendered after publish in IIS

ASP.NET MVC Bundle not rendering script files on staging server. It works on development server

ASP.NET MVC framework 4.5 CSS bundles does not work on the hosting

Why is my CSS bundling not working with a bin deployed MVC4 app?

Error:

enter image description here

CSS Shows In Server Like This

<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

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

2 Answers 2

8

Solved , just add

BundleTable.EnableOptimizations = false;

in ~/App_Start/BundleConfig.cs

Sign up to request clarification or add additional context in comments.

Comments

3

For the fonts part you can use this in your 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.

3 Comments

I have used font part in web.config , but issue is same
Can you try the bundles without the new CssRewriteUrlTransform() ?
Yes but same issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.