1

I am using the css property:

background-image: url(/Content/Images/background.jpg);

However when deployed to Windows Azure, it comes up with the file not found error because it is trying to retrieve the image from:

...azurewebsites.net/bundles/Content/Images/background.jpg

I have tried:

'~/', '../', 'Content/', '/Content' & even the full path.

when I simply go to the url of the image in the web browser, it loads the image so I know it is there.

What is the best way to remove or account for this problem?

Thanks.

Tom
  • 195
  • 2
  • 12
  • 1
    Please check if you have bundling enabled in your application. The file you want to check is `BundleConfig.cs` in `App_Start` folder. – Gaurav Mantri Sep 12 '15 at 07:03

1 Answers1

1

Why is Windows Azure adding '/bundles/' into all of my css image file paths?

Your CSS file is getting bundled. ASP.NET is putting your CSS file into a new file and storing it at mydomain.net/bundles/somefile.css. The web browser is looking for your image relative to the CSS files location.

This is only happening on Azure because bundling only runs in release configuration not in debug configuration. So, you can test bundling locally by setting <compilation debug="false" /> in your web.config file.

What is the best way to remove ... this problem?

Take a look at this: MVC4 StyleBundle not resolving images and this MVC cannot display image using background-url in css - uses bundling, or just do not use bundling. :)

Community
  • 1
  • 1
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467