Registering Master Pages in ASP.Net Web Configuration

Apply a Master Page to every content page in a particular folder or every content page in an entire application. Rather than add a MasterPageFile attribute to individual content pages, you can add a configuration option to the web configuration file.

Web.Config

<configuration>
<system.web>
<pages masterPageFile=”~/DemoMasterPage.master” />
</system.web>
</configuration>

The Master Page is applied only to content pages. If a page does not contain any Content controls it is a normal ASP.NET page then the Master Page is ignored.

You can override the Master Page configured in the web configuration file in the case of a particular content page. In other words, a MasterPageFile attribute in a content page takes precedence over a Master Page specified in the web configuration file.
Tags:
Hot on Web:


About author