Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My images ,css,and any other referred files are not displayed in my locally hosted site.but while running everything is proper.

I refer files like
"../../FoodImages/abcd.jpg"


If my project name is ProjectTest,in My visual studio heirarchical structure is ProjectTest/FoodImages/abcd.jpg.And it is properly working.If i had published my project to a folder MySite,the folder FoodImages comes like MySite/FoodImages/abcd.jpg.


Same is the case with my Site.css,

I have refered like

<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />



I have tried using '~',but it neither worked.for eg:
return File(Server.MapPath("~/Documents/menu.pdf"), contentType:"application/pdf");



Please help me out.Its properly working when not hosted.
Posted
Comments
massab 30-Oct-12 3:34am    
"@Url.Content("~/Content/Site.css")" can be used for href.
But wat about code in COntroller ,ap.Image = "../../FoodImages/abcd.jpg";

1 solution

It's a common problem in the MVC deployment. Please try to change the reference like the following.
HTML
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css"/>


Note:
HTML
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
will work only in devlopment environment.

Please revert back, if you face any issue.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900