With anonymous access configured for the SharePoint web application in the Configuring anonymous access for web applications recipe, anonymous users are now able to access the SharePoint web application. Without granting anonymous users access to the content itself, SharePoint will display the generic Access Denied error page when trying to access the content. In this recipe, we will configure anonymous access for the site content.
Follow these steps to configure anonymous access to the site content:
Content in SharePoint is only made available to users who have the appropriate access to the content. Configuring anonymous access at the site level provides anonymous users with appropriate access to the content. Without access to the content, anonymous users would receive the generic SharePoint Access Denied error page.
Configuring anonymous access at the site level may also be accomplished with PowerShell or code using the server-side object model.
Follow these steps to configure anonymous access to site content with code using the server-side object model:
using
statement as follows:using (var site = new SPSite("http://sharepoint"))
using
statement as follows:using (var web = site.OpenWeb())
AnonymousState
property to On
as follows:web.AnonymousState = SPWeb.WebAnonymousState.On;
web.Update();
3.145.61.170