Search code examples
dotnetnuke

Identify if a user is logged in in a page in Dotnet nuke


In my dotnetnet Nuke project, I have to put a sentence in a page for signed (logged in) users. And I have to put another sentence for unsigned users. How can I do this?


Solution

  • You can use the same code that's written in login skin object here: https://github.com/dnnsoftware/Dnn.Platform/blob/30bd1a1bd9d2962a36f6e39403f00ba5877dcfab/Website/admin/Skins/Login.ascx.cs#L84

    Visible = (!PortalSettings.HideLoginControl || Request.IsAuthenticated) && (!PortalSettings.InErrorPageRequest() || ShowInErrorPage);

    You can only use Request.IsAuthenticated in your case as well.

    -- old answer --

    Use login skin object provided by dnn to do so.