Similar to the previous recipe, it is common to display certain content on a page only to users who have not logged in. In this recipe, we will add some content to our customized master page that only anonymous users can see.
To see the results of this recipe, you will need to be able to access the SharePoint site both anonymously and logged in.
To display specific content only to anonymous users, we will use the following steps:
seattle.master
(for our example, we have renamed it Seattle_DisplayAnonymousContent.master
).Seattle_DisplayAnonymousContent.master
master page.Seattle_DisplayAnonymousContent.master
master page.ID_SuiteBarBrandingDelegate
ID.<asp:LoginView>
control with content in the AnonymousTemplate
.<asp:LoginView ID="customLoginView" runat="server"> <AnonymousTemplate> <span style="color: #FFFFFF; float: right;">Only Anonymous Users Can See This</span> </AnonymousTemplate> </asp:LoginView>
The ASP.NET LoginView
control is a simple server control that can have a template for logged in users and a template for anonymous users. The AnonymousTemplate
content only renders when a user is not logged in. In this recipe, we added text to the AnonymousTemplate
that only users who are not logged in should see.
18.188.37.136