Creating an application page for sharepoint is fairly simple and straight-forward. To make that application page secure, just do some extra steps in the code. Here is the code-snippet for creating secure application page in sharepoint .
public partial class SampleSecurePage : Microsoft.SharePoint.WebControls.LayoutsPageBase { public SampleSecurePage() { //In the constructor define rights check mode to be done on the pre-init event this.RightsCheckMode = RightsCheckModes.OnPreInit; } //get the permission set from spbase permission enumeration protected override SPBasePermissions RightsRequired { get { SPBasePermissions permissions = base.RightsRequired; return permissions; } } protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); Microsoft.SharePoint.SPWeb _Web = SPControl.GetContextWeb(Context); //dynamically assign the master of the current spweb to the application page this.MasterPageFile = _Web.MasterUrl; if (!HttpContext.Current.User.Identity.IsAuthenticated) { //re-direct the user to log-in page and authenticate } } protected void Page_Load(object sender, EventArgs e) { //do some logic here } }
Pingback: Create secure application page for sharepoint - My experiments with SharePoint, Azure and .NET using Visual Studio