I'm developing a website in ASP .NET MVC 2 using C#.
I have a partial view, Header.ascx
. In there I have an image for my website, MainImage.png
.
When I use one of the primary Views I've created, the image shows up fine. For instance, I hit the Index ActionResult of my News Controller. (site.com/News
)
However, when I dig deeper, I seem to lose my image, even though the Partial view is being displayed from the Master page. i.e., if I try going to site.com/News/Article/1
Are there any suggestions for keeping my image fully intact, such as a way to do absolute pathing?
The code I currently have in my partial view is here:
<div align="center"><a href="/"><img src="../Content/images/MainImage.png" style="border:none" /></a></div>
I've tried changing the src to ~/Content/images/MainImage.png
but that breaks it all over the site.