when specifying the src of an img tag, must i convert the relative path to absolute? please post examples and why not use runat=”Server”
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because ASP.NET MVC views are in a separate folder, your best option is to use the
to get the exact path of the image.
All Url.Content does is return the exact path of a specific file using its relative url so it can be used for ANY file in your web application (.js .css .txt etc.).
Alternatively, a better implementation for images is Html.Image() which is available in the MVC Futures (I can’t find the .dll link) and I think in the new version of ASP.NET MVC
If you can’t find them, check out this post
Where is Html.Image in ASP .NET MVC RC?