2

How do we make the pages what we created using Visual Studio inherit permissions?

They work fine when the person is signed on, but when they are anonymous, you cannot access the pages.

How do I get them to be visible for anonymous users?

Thank you.

2 Answers 2

4

I assume that by saying

pages what we created using Visual Studio

you mean application pages created in Visual Studio and deployed to _layouts directory. If you want to make such page anonymous, you have to change base class in your code behind. By default, application pages inherit from LayoutsPageBase class, and you have to change it to UnsecuredLayoutsPageBase and you have to override property AllowAnonymousAccess to return true:

public partial class ApplicationPage1 : UnsecuredLayoutsPageBase
{
    protected override bool AllowAnonymousAccess 
    {     
        get
        {        
            return true;      
        }  
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }
} 

Of course your web application also must have anonymous access enabled.

Creating a SharePoint Application Page for Anonymous Access

0
1

Start at the web application and continue to the appropriate level. Here is the PowerShell commands. (I assume you can Bing for steps in the user interface.)

Web Application:

$wa = get-spwebapplication http://[your_url_here]
$zone = [Microsoft.SharePoint.Administration.SPUrlZone]::WhicheverApplies
$i = $wa.IisSettings[$zone]
$i.AllowAnonymous = $true
$wa.Update()
$wa.ProvisionGlobally()

Site:

$w = Get-SPWeb http://[your_url_here]
$w.AnonymousState = [Microsoft.SharePoint.SPWeb+AnonymousState]::On // or Enabled for lists & libraries only
$w.Update()

List:

$w = Get-SPWeb http://[your_url_here]
$l = $w.Lists["List_Name"]
$l.AnonymousPermMask64 = {BasePermissions as appropriate}
1
  • Is this different from adding anonymous access through Site Actions -> Site Permissions -> Anonymous Access?
    – Diana
    Commented Mar 19, 2013 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.