While it's not the complete picture, you can see a BasePage as a way to express common behavior
and a Master Page as a way to express common look and feel
Let's take a look at how a page normally works before you use a BasePage. Each of your pages in your web site inherits from System.Web.UI.Page
. This gives each page the behavior defined in this class, and gives you access to stuff like the Title, Request, Response and much more. The Page class itself inherits from another class (TemplateControl) which in turn inherits from Control which inherits Object. The full hierarchy looks like this:
Now, with a BasePage, things change a bit. Rather than inheriting from System.Web.UI.Page, your page now inherits your BasePage that in turn inherits Page:
This way, your ASPX now contains all the behavior that is defined in BasePage. The total behavior of BasePage is a combination of everything that is defined in System.Web.UI.Page (where it inherits from) plus everything that BasePage itself defines. For example, in the TIO on page 206 you'll learn how to add behavior that checks whether your ASPX page has a valid title. Your pages that inherit from BasePage now automatically get this behavior for free; all they need to do is inherit from BasePage (which you can state in the Code Behind of each ASPX page) and then the title is checked automatically at run-time.
Master Pages on the other hand define look and feel. As you learned in the beginning of chapter 6, a Master Page allows you to define regions that you need on every page in your site (at least, on the pages that use a specific Master Page). It allows you to define repeating areas like menus, footers, headers, banner areas and so on. Each page that is based on this Master Page automatically gets these regions; all it needs to do is express that it uses a Master Page (using the MasterPageFile attribute) and then fill in one or more of the ContentPlaceHolder controls that the Master Pages defines (using <asp:Content /> blocks).
Once you make a layout change to the Master Page (like adding a menu), all pages based on this Master Page automatically pick up that change.
You don't have to use a Master Page and you don't have to use a BasePage. Additionally, you can have only one of them, or both at the same time. Since they are for a large part offering non-overlapping functionality, it's perfectly OK to have an ASPX page that inherits from BasePage and that is based on another Master Page.
I usually always create my intermediate BasePage on any new web site, even if I don't have specific behavior for it. Once every page is inheriting from this BasePage, it's really easy to add behavior later. For example, if you decide you want to set some meta tags like Keywords or Description on every page, you could do this in the BasePage and all pages in your site would automatically pick up the behavior.
Hope this clarifies things a bit. If not, please let me know.
You have a Merry Christmas too!