I'm new with MVC (V4) and I have an issue after publishing my site to IIS. My site works perfectly when viewed in IIS express though the web browser (and page inspector). However, when I publish my website (through VS2012) to IIS all my Images being references from my CSSs are broken.
My CSS folder is as follows:
My Images folder is:
<strong>The folder structure is identical both on IIS virtual directories and my project directories.</strong>
All my images are referenced like this:
When I change my CSS references to
../Images/MyImages/image.jpg it starts to work again.
This does not consists to the actual physical folder paths of the IIS application/Virtual directory.
I will appreciate any help solving this out.
If you are using bundles you should use ~/ eg.
@Styles.Render("~/bundles/stylebundle") in your views.
When defining your bundles always start the file paths with ~/. eg
Any paths in your css should be relative to the css file itself.
I've just built a test site using the same structure you have and sticking to what I've written above and it all works in both debug and release. To fake the release mode on your local machine inyour bundle config file add
BundleTable.EnableOptimizations = true;