As Darren explained, we’ve been working on a new ASP.NET 2.0 application for a client using the ASP.NET Web Application Projects (preview) download.
We discovered that you lose design-time support for Master Pages if you set the masterPageFile in the <pages> section of web.config (the recommended way), rather than at the top of every web form, like so:
<pages masterPageFile="~/Site.Master" />
You get a nice error control that says “Content controls can only be used in a content page”

The workaround that Darren came up with was to set MasterPageFile to an empty string at the top of the aspx web form.
<%@ Page Language="C#" MasterPageFile="" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>
This works in design-time, (except you can’t see the master page content), but what I have found is that it doesn’t work at run-time! You end up with an exception:
System.Web.HttpException: Content controls are allowed only in content page that references a master page.
And since we’ve specified a blank Master Page at the page level, it seems to override the setting at the web.config level.
The Solution
As far as I can tell, you just have to cave in and set the masterPageFile at the top of every Web Form, until they fix this.
3 Comments
Yes it is an annoying problem. Another feature U would like is to be able to hide all the master page content (as some master pages can be quite complicated and slow to load in the IDE) and view only the child/slave page you are working on.
Thanks Darren,Despite the title of my original post, I think I agree with your post but one of the major problem i experienced that master pages takes time to load sometime its hangs and complicated too.
There is one thing you can do, You set the directive to "" as you did. Then if you’re using a base class for your pages (the inherit attribute in web.config does at least work), you can override the PreInit function to set it programatically. You can even get the setting from the web.config file.The form of the PreInit is shown here:http://www.odetocode.com/Articles/450.aspxYou’ll still get a complaint in the errors box in Studio about it being set to nothing, but the page will work in design view and on the site and you’ll just have two red squigglies in code view.But with all that work, it seems easier just to set the thing on every page..haha. I hope this gets fixed eventually..