LoginView Control in ASP.NET Whidbey

First off, special thanks to Stephen Walther for his article on the new security features in Whidbey

I have been looking at the Login controls in Whidbey with great interest given all the cool code that comes with them.  I think that the LoginView Control can give you some interesting data, if you configure it correctly.  I spent a couple of minutes putting it into a form that I can use.  Basically, here is the idea:

  • Anonymous users.  They get the anonymous template information.
  • Logged on users.  They get the logged on user template information.
  • Role users.  These users get the logged on information specific to the role to which they belong in the application.

Here is the configuration for the LoginView Control.  It is fairly simple, but the idea is powerful.

        <asp:LoginView ID="LoginView1" Runat="server">
            <AnonymousTemplate>
                User is not logged in.<br />
            </AnonymousTemplate>
            <LoggedInTemplate>
                User is logged in.<br />
            </LoggedInTemplate>
            <RoleGroups>
                <asp:RoleGroup Roles="Admin">
                    <ContentTemplate>
                        You are an Admin User.<br />
                    </ContentTemplate>
                </asp:RoleGroup>
                <asp:RoleGroup Roles="User">
                    <ContentTemplate>
                        You are a Regular User.<br />
                    </ContentTemplate>
                </asp:RoleGroup>
            </RoleGroups>
        </asp:LoginView>   

The would be very powerful in a footer or some similar location on each page of an application.

Wally

4 Comments

Comments have been disabled for this content.