4

I have an using ASP.NET MVC 4.5 that uses some css files. The css refers to some images.

The css file Is located in this path:

WebSiteRoot\Content\css\services\File.CSS

The image is located in this path:

\WebSiteRoot\Content\img\servicesbubble\image.png

The css has this calling:

background:transparent url('../../img/servicesbubble/image.png') no-repeat 0px 0px;

When I run the app in the localhost it works. But when I upload to the hosting (Appharbor) It doesn't work. Why? What is the best way to reffer to the root of an app?

In the server the http get is tried to this wrong URL

WebSite.com/img/servicesbubble/desktop.png

Update: I am using the .NET framework 4.5 feature called bundling for merge these CSS with another CSS.

4

3 Answers 3

2

Your problem is actually coming from the fact you're minifying the css to a different directory than the CSS originally existed in.

More specifically: http://tulpepwebsite.apphb.com/Content/css/servicescss?v=sdm08D5sRu2I00dA0phyVTYZ_QU8Nfp27wHtmmE0Gzk1

So ../../ puts you at http://tulpepwebsite.apphb.com/Content

Urls in CSS files are always relative to location of the CSS file itself.

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

2 Comments

I dont think so. The minification and bundling in MVC 4.5 allows this.
Does bundling rewrite the paths in the minified CSS? (clarification)
2

Your paths to the CSS files seems to change. The two CSS files I see related to your website are http://tulpepwebsite.apphb.com/Content/css/servicescss?v=sdm08D5sRu2I00dA0phyVTYZ_QU8Nfp27wHtmmE0Gzk1 and http://tulpepwebsite.apphb.com/Content/GeneralCSS?v=9kvtUcooQua0D4nQT8wZ-4_Gm6OcRd-J5SkjMxwKiyQ1. (The other is from the google fonts service.) You need to figure out why that's happening.

Edit: Ok, I'm going to guess something. You're probably using the new ASP.NET 4.5 bundling feature. But it doesn't make sense to bundle CSS flies in different directories, if you're doing that.

1 Comment

I am using the bundling feature of ASP.NET 4.5, and I am not bundling css in differente directories. I have sense in term of compress and simply your code.
0

Your CSS location is different than you think:

WebSiteRoot\Content\css\File.CSS

instead of

WebSiteRoot\Content\css\services\File.CSS

Comments

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.