Naju
Naju

Reputation: 1541

MVC4 - URL path issue

I am very new to MVC 4. Here I am facing a issue related to URL reference of assets.

I have used bundle configuration to render my css and scripts.

@Scripts.Render("~/Content/scripts/location")

One of my script is using URL of a CSS and that CSS uses some images.

1.Image issues:

Actual reference : http://localhost:58752/Scripts/lib/sample/img/east-mini.png

404 error with following link http://localhost:58752/Location/img/east-mini.png

2. CSS reference issue

Actual reference :http://localhost:58752/Scripts/lib/sample/theme/default/style.css

404 error with following link http://localhost:58752/Location/theme/default/style.css

Please help me to resolve my issue.

Upvotes: 0

Views: 62

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

Images and other resources inside a CSS file should always be referenced as relative to the location of this CSS file itself.

So for example if you have Location/theme/default/style.css and wanted to reference Location/theme/images/foo.png you should use ../images/foo.png inside your CSS.

Upvotes: 1

Related Questions