This project is read-only.

check auth in EasyControl

Topics: Developer Forum
Feb 28, 2011 at 9:01 AM

In my EasyControl ascx file I would like to control the content based on Anonymus/Authenticated


If anonymus

<p>this is shown to anonymus users </p>

If Authenticated

<p> this is shown to authenticated users </p>

What asp do I have to put around these <p> tags



Feb 28, 2011 at 3:27 PM

Hi Henrik,

Try the following;


<% if (Page.User.Identity.IsAuthenticated){ %>

Authenticated content here

<% } else { %>

Unauthenticated content here

<% } %>


For use with roles substitute the IsAuthenticated line with:

<% if (Page.User.IsInRole(MyWebPagesStarterKit.RoleNames.Administrators.ToString())){ %>


Mar 6, 2011 at 2:06 PM

There is a LoginView control for that.

<asp:LoginView id="lv" Runat="server" >
You are not logged in.
here is a lot of stuff you can see when you are logged in ...

Also check out the LoginStatus and LoginName controls.