Why in ASP.NET MVC, is there a ContentPlaceHolder for the title?

asp.net-mvc

Solution

See this post.

Problem

In a new ASP.NET site there is a ContentPlaceHolder for the title: ``` <head runat="server"> <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title> <link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> </head> ``` In the page: ``` <asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server"> About Us </asp:Content> ``` Why is this? Why can't the title property/attribute be used on the page directive? ``` <%@ Page Title="About Us" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> ``` Both methods have the same result. For me the ContentPlaceHolder approach seems hackish. If you needed a dynamic title you can do it like this in the aspx page: ``` <%= this.Title = "About Me" %> ```

Original source