Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

1 Answer 1

up vote 5 down vote accepted

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">
                <AnonymousTemplate>
                    Please log in for personalized information.
                </AnonymousTemplate>
                <LoggedInTemplate>
                    Thanks for logging in 
                    <asp:LoginName id="LoginName1" runat="Server"></asp:LoginName>.
                </LoggedInTemplate>
 </asp:LoginView>
share|improve this answer
    
Thank you! Works a treat! –  Anonymous Feb 24 '10 at 4:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.