Showing posts with label Layout Pages. Show all posts
Showing posts with label Layout Pages. Show all posts

Wednesday, March 30, 2011

SharePoint Layout Page for Only Administrator Accessible

SharePoint Layout (Application) pages are accessible by any user who has a least possible access/permissions for any of the sites in the server/farm.

A layout page access can be restricted to only Site Administrator by overriding the RequireSiteAdministrator property of LayoutsPageBase class.

The below code snippet shows sample implementation.
using Microsoft.SharePoint.WebControls;
public class MyLayoutPage : LayoutsPageBase
{
//It mmakes sure only site administrators can access this page
protected override bool RequireSiteAdministrator
{
get
{
return true;
}
}
protected void Page_Load(object sender, EventArgs e)
{
//Code goes here...
}
}
It is just one of the members, look at the post here to know about many other members/methods of LayoutsPageBase class.