Search code examples
asp.net-mvccontentplaceholder

ASP.NET MVC ContentPlaceHolder overriding hard-coded content


This is what I have in the aspx page:

<head runat="server">
    <title>Website - <asp:ContentPlaceHolder ID="HeadContent" runat="server" /></title>
</head>

This is what's in the view:

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    Homepage
</asp:Content>

For some reason, this HTML is generated:

<title>Homepage</title>

The 'Website - ' part is getting removed. Anybody know how I can fix this?


Solution

  • Phil Haack has an explanation of this issue (and a work-around) at http://haacked.com/archive/2009/04/03/tipjar-title-tags-and-master-pages.aspx . The work-around is that you use an asp:LiteralControl for the static part of your page title.