简体   繁体   中英

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)

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM