Customizing the DNN login Header Stack

dnn-logo

The DotNetNuke default login could just use a little work in my experience. I use a customized login stack in most of my skins that includes a login and register link for unauthenticated users, and a Welcome and profile message for logged in members.

To get everything working I use a simple conditional IsAuthenticated. Coupled with an else and end if I have the logic in place for this user interface.

1
2
3
4
5
6
7
8
<div id="login">
      <% If Request.IsAuthenticated Then%>
               If logged in do this
     <%  Else%>
              If not logged in do this
      <% End If%>
              Always do this.
 </div>

I can welcome logged in usernames with a dnn:USER token

1
2
3
<% If Request.IsAuthenticated Then%>
     Welcome: <dnn:USER ID="Username" runat="server" /> | <a href="/User-Profile/">Profile</a> |
<%  Else%>

Next I add a link to my registration page for unauthenticated users only.

1
2
3
<%  Else%>
    <a href="/Register">Register</a> |
<% End If%>

The final piece is the dnn:Login element, that shows either a login or logout button

1
<dnn:LOGIN ID="dnnLogin" CssClass="LoginLink" runat="server" />

And putting it all together:

1
2
3
4
5
6
7
8
<div id="login">
      <% If Request.IsAuthenticated Then%>
               Welcome: <dnn:USER ID="Username" runat="server" /> | <a href="/User-Profile/">Profile</a> |
     <%  Else%>
         <a href="/Register">Register</a> |
      <% End If%>
         <dnn:LOGIN ID="dnnLogin" CssClass="LoginLink" runat="server" />
 </div>
This entry was posted in DotNetNuke, Snippets and Demos.