I have content that I only wish to display to anonymous users.

Once the user has logged in, I would like to hide it.

Is "Audience Targeting" the right way to do this, and if so, it seems I can only choose 'All Site Users" as the group to target. Is there a specific group I could create that includes ONLY anonymous users?

  • 2
    Keep in mind that Audience Targeting only hides/shows content to certain audiences, it doesn't make it inaccessible. With 'URL-hacking' (e.g. changing the id from 2 to 3 in the url) or 'Show all content' the content can be seen.
    – Dribbel
    Feb 23 '10 at 8:09

Possibly the most common approach for dealing with this is to use the ASP.net LoginView control. In your master page/page layout/whatever, simply wrap the markup/controls you wish to display to authenticated/anonymous users in a LoginView control - this will allow you to easily specify who should see what.

Effectively you don't need to do anything 'SharePoint' here - this all works because SharePoint is built on top of ASP.net, and ASP.net knows whether the current user is authenticated or not.

A simplified extract from the MSDN sample at the link above:

<asp:LoginView id="LoginView1" runat="server">
                    Please log in for personalized information.
                    Thanks for logging in 
                    <asp:LoginName id="LoginName1" runat="Server"></asp:LoginName>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy