| In the past few months I’ve gained some experience in building custom application pages. And I wanted to share some things I’ve come across while building those pages. First of all when provisioning these pages, you have two choices of folders to put them in. - ADMIN folder, use this folder when your application pages should be accessed only via the Central Admin.
- LAYOUTS folder, use this folder when developing application pages that can be accessed by every web or site.
Next to those two folder options you also have the choice of which masterpage to use. When creating Application Pages that end up in the - ADMIN folder (12hive/Templates/ADMIN) attach the following masterpage:
<%@ Page Language="C#" MasterPageFile="~/_admin/admin.master" Inherits="Custom_Solution.Custom_Class" %>
<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master" Inherits="Custom_Solution.Custom_Class" %>
<%@ Page Language="C#" MasterPageFile="~/_layouts/layouts.master" Inherits="Custom_Solution.Custom_Class" %> <%@ Page Language="C#" MasterPageFile="~/_layouts/simple.master" Inherits="Custom_Solution.Custom_Class" %>
Below is a finding of some weird behavior I came across when I accidently was referring to a masterpage that was in another folder than the page.
- Page location: ADMIN folder
Referenced masterpage: ~/layouts/simple.master
- Symptom : Simple page with some TextBoxes that were loaded with data from a database and at the bottom a button to save changes. When I clicked the button I immediately got a “The security validation for this page is invalid” error.
- Solution : Change the masterpage to ~/_admin/admin.master or to ~/_layouts/application.master
So I reckon it’s best to use the masterpages that you can find in the corresponding folder. Just to avoid the troubles you might get ;)
|