Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Check if user logged in with inline .Net View modes: 
User avatar
Member
Member
Chunda - 6/22/2009 9:37:19 AM
   
Check if user logged in with inline .Net
Hi,

I have a static HTML area which has some links to various parts of the site and I want to add a login/logout hyperlink within the list is there a way to check this with some inline .NET e.g.

<a href="Menu1.aspx">Menu1</a>
<% if UserLoggedIn() then %>
<a href="Login.aspx">Login</a>
<% end if %>
<a href="Menu2.aspx">Menu2</a>

Thanks
Paul

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 7/2/2009 3:33:30 AM
   
RE:Check if user logged in with inline .Net
Hi Paul,

You can create custom macro where you can check if user is logged in and return appropriate link. You can use following sample code to check if user is logged in:

if (CMSContext.CurrentUser.IsPublic())
{
//no user is logged in
}


Best Regards,

Martin Dobsicek