While creating the unsecured application pages like Login,User Registration Pages especially for FBA sites in SharePoint ,we should be inherting our page from the base class ‘UnSecuredLayoutsPageBase’ like below.
// inherit the page from Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase instead of Microsoft.SharePoint.WebControls.LayoutsPageBase
public partial class UserRegistrationPage : Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnPreInit(EventArgs e)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
base.OnPreInit(e);
Microsoft.SharePoint.SPWeb _Web = SPControl.GetContextWeb(Context);
this.MasterPageFile = _Web.MasterUrl;
});
}
}
but the above class implementation will fail when you test after deploying it,actually what it does is while you try to load the UserRegistrationPage from browser it automatically redirects to ‘Login’ page which is available inside thej IDENITYMODEL/Forms folder.
To resolve the issue,you need to add/override the AllowAnonymousAccess property and return true along with AllowWebNull in your custom application page and this should resolve the problem.
//override the allow anonymous property to true
protected override bool AllowAnonymousAccess
{
get { return true; }
}
protected override bool AllowNullWeb { get { return true; } }




