Thursday, May 24, 2012

Create Anonymous Access page in Extranet SharePoint Application (FBA)

 Create Anonymous Access page in Extranet SharePoint Application (FBA)

1.    Create Application page in the layouts folder
2.    Change master page default.master to simple.master
3.    Replace Codebehind base class LayoutsPageBase  with UnsecuredLayoutsPageBase
4.    Override AllowAnonymousAccess method
5.    Add a location path tag to webapplication web.config file.

replace DynamicMasterPageFile with MasterPageFile as shown below

remove below code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationPage1.aspx.cs" Inherits="Membership.ApplicationPage1" DynamicMasterPageFile="~masterurl/default.master" %>


Replace with
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationPage1.aspx.cs" Inherits="Membership.ApplicationPage1" MasterPageFile="~/_layouts/simple.master"   %>


simple.master

This master is used by login and error pages. To customize these pages, a replacement page must be created and stored in the _layouts directory on the server. For more information see Default Master Pages in SharePoint  on MSDN.
Pages using simple.master
·         Login.aspx
·         SignOut.aspx
·         Error.aspx
·         ReqAcc.aspx
·         Confirmation.aspx
·         WebDeleted.aspx
·         AccessDenied.aspx

Learn more about master pages

public partial class ApplicationPage1 : UnsecuredLayoutsPageBase // LayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected override bool AllowAnonymousAccess
        {
            get
            {
                return true;
            }
        }
    }

Add below tag it to your webapplication web.config file
C:\inetpub\wwwroot\wss\VirtualDirectories\portno
<location path="_layouts/Membership/Applicationpage1.aspx">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
 

2 comments:

Followers