3

When I debug my ASP MCV 4 Application on Visual Studio 2012, CSS displays properly. I deployed it to IIS 7, but I notice that not all the CSS is working as It was in local , some styles are missing. I've edited the render string so that It does not resemble to my actual directory structure as it's said here but I didn't get the good result . Any idea how to handle this issue ?

Update

In order to publish my app:

  • I've used button publish ( in VS 2012)
  • Choose file System (publish method)
  • Browse the application from IIS manager

When clicking on F12 : I got these messages "Failed to load resource: the server responded with a status of 404 (Not Found) " It's about some images that are not found

And I'm using bundles to include CSS files

enter image description here

ItShine
  • 349
  • 1
  • 4
  • 22
  • Identify which CSS *is* loading and which is not, and then from there check the paths you've linked to - is a place to start. – sheriffderek May 07 '14 at 13:48
  • 1
    If you are getting no Css in IIS, check that Static Content is installed in the IIS setup using the Programs and Features applet in Control Panel, that tripped me up on IIS 8 – Slicksim May 07 '14 at 13:54
  • Can you improve your question by explaining the steps you did to debug and the results you got? Did you try using Firebug or a similar tool (CTRL+ALT+I in Chrome/Firefox, F12 in IE)? Are the CSS files correctly downloaded from server? How do you include CSS files? Are you using bundles or what? – winterlude May 07 '14 at 14:07
  • @winterlude did you see my update ? Did I mentioned what you'd know ? – ItShine May 07 '14 at 14:36
  • @Slicksim I've checked Static Content and it's installed annd checked – ItShine May 07 '14 at 16:08

5 Answers5

2

try

BundleTable.EnableOptimizations = false;

In bundle config

Thisara Subath
  • 635
  • 6
  • 16
0

Just remove the App_Themes Folder in Request Filtering Feature.

IIS7 -> Site -> (Ursitename), in the right panel it has"Request Filtering",

open the feature and remove the App_Themes Folder from it. and refresh and browse.

It's not an IIS matter.

  1. Check if CSS is the same on both servers (maybe you didn't deploy correct css file).
  2. Check if it is not a cache issue (clean all browser cache).
  3. Check in another browser.

IE has developer tools (F12). Check if that header has the same css style in both versions...

Also Check by giving the correct path,

Since the problem occurs on CSS only, do you use full path to CSS?

<link href="http://pcname/website/file.css" rel="Stylesheet" type="text/css" />

Use this

<link href="file.css" rel="Stylesheet" type="text/css" />

If not, than it might be also some permissions issue. Then you locally browsing http://local it would use your local account, when browsing http://pcname you will be recognized as a remote user who might have no rights to access css file or folder.

KesaVan
  • 1,031
  • 16
  • 32
0

It might happen that the HTTP request for a bundle is handled by IIS instead of the MVC framework. This kind of routing conflict may happen when the virtual path of the bundle matches a real path on the file system.

As stated at the end of the official ASP.NET documentation (http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification):

A good convention to follow when creating bundles is to include "bundle" as a prefix in the bundle name. This will prevent a possible routing conflict.

Therefore, I suggest you rename your bundles making sure that the name is not similar to any path in your website.

You can take a look at the answers to these similar issues:

Community
  • 1
  • 1
winterlude
  • 131
  • 6
0

I've finally found the solution , and It's to add this line in the BundleConfig :

BundleTable.EnableOptimizations = false;
ItShine
  • 349
  • 1
  • 4
  • 22
  • Doing this, you disabled the optimizations made by the bundles for both the Debug and Release mode! Therefore, you completely loose the advantages of using them. At this point, including CSS and JS through bundles makes no sense - it's easier to directly include them into the HTML layout. If with this setting the code runs successfully, it means that your problem was due to the conflict that I described in my answer. – winterlude May 09 '14 at 15:00
  • Oh really ! Then I will try what you've said in your answer I hope It'll work but anyway thank you so much for reply – ItShine May 09 '14 at 15:18
0

I fixed my issue commenting the static file handler on the webconfig

  <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
Cesar Vega
  • 455
  • 6
  • 15