Search code examples
imageasp.net-mvc-4iis-7.5http-status-code-404

Images not loading through CSS on IIS7.5 MVC4


My web app(MVC4) is hosted on IIS 7.5, Windows 7 Ultimate with .net framework 4.0 and 4.5 installed. On hosting the application, the images are not rendered, giving me a 404 error

enter image description here

The content type is "Text/html" shouldn't it show as "image/jpeg or png"?

On giving the image path directly, the image is rendered, but not through css. The css is loading, as my layout is intact.

I have gone through many questions related to the same issue, have included

<modules runAllManagedModulesForAllRequests="true" />

checked for Static Content under IIS>WWW Services in control Panel, applied hotfixes (http://support.microsoft.com/kb/980368).. in vain.

My css code is as below,

body{background:url(images/bg.jpg);

image folder structure is

  • ABC
    • images (folder)
      • bg.jpg
    • main.css

(have tried giving the image path along with .. and /, no use)

ExtensionlessUrlHandler, are present in the webconfig, hosted on .net framework 4.0 (integrated),

My IIS also co-hosts MVC3 application, which runs fine.

Not sure what is the issue? I am missing something, which hasn't been tried yet, your help would give me some sleep.

Update:

Refering to this post

I changed the bundle according to the answer by Calgary Coder, the image is loading now.


Solution

  • As per this post,

    I changed my bundle (as per below format/pattern)

    bundles.Add(new StyleBundle("~/Content/css/jquery-ui/bundle")
           .Include("~/Content/css/jquery-ui/*.css"));
    

    And the images are loading now. Thanks to Calgary Coder.