Reputation: 37
I'm using a custom theme based on "Contoso". I've edited the "Branding" file in my custom theme to show my logo:
@{
var homeUrl = Href("~/");
}
<h1 id="branding">
<a href="@homeUrl">
<img src="Themes/myTheme/Content/Images/logo.png" alt="Our Logo" />
</a>
</h1>
I can see the logo fine on regular pages. I've got a list of custom content items on one of my pages though, and when I click on the title of one of the content items in the list to show the details of the item, the logo at the top shows as a broken image... What would cause this?
Upvotes: 2
Views: 1381
Reputation: 1
Use ~/ as sugested, @Html.Content("~/...
The compiler tracks the route and makes the URL from the site root, ie, ~/ is replaced by the site's root.
Upvotes: 0
Reputation: 1
It is better to use
<img src="@Html.Content("~/Themes/myTheme/Content/Images/logo.png")" alt="Our Logo" />
Upvotes: 0
Reputation: 9431
Use
<img src='@Href("~/Themes/myTheme/Content/Images/logo.png")' alt='Our Logo'/>
Your img url path was not defined as relative to the root. More info here: http://brugbart.com/Articles/paths
This should also work: Notice the '/' at the beginning of the url
<img src="/Themes/myTheme/Content/Images/logo.png" alt="Our Logo" />
Upvotes: 4