mola10
mola10

Reputation: 986

asp.net mvc 3 routing,resource

i use route

routes.MapRoute(
                "Search",
                "search/{categories}/{sections}/{actions}",
                new { controller = "home", action = "search", categories = 0, sections = 0, actions = string.Empty }
                );

sample : localhost:4304/search/64/0/0

Error (500 or 404) during loading resources because the way href="../../Content/Images/favicon.ico"

conducts not to localhost:4304/Content/Images/favicon.ico

but conducts to localhost:4304/search/Content/Images/favicon.ico (not found)

Problem with all resources (css, img, js)

Upvotes: 1

Views: 368

Answers (1)

Milimetric
Milimetric

Reputation: 13549

It's not a good idea to reference your resource files like that. The best way is to spit out links to them with:

@Url.Content("~/Css/etc.css")

And if you have any images that you need from CSS, just put them in a folder under CSS (example: ~/Css/Images/myImage.jpg) so you can access them from CSS like this:

background-image: url(Images/myImage.jpg)

Now, that being said, the favicon.ico should be in the root of your website and nowhere else, do you have some other situation?

Upvotes: 3

Related Questions