LoginStatus for ASP.Net MVC?

How can I get LoginStatus for ASP.Net MVC? I can connect and authenticate to MVC, but I'm not sure how to get LoginStatus, can anyone help?

+4
source share
1 answer

When you create a new MVC project, the csproj template creates a partial view called "LoginUserControl" located in ~ / Views / Shared / LoginUserControl.ascx.

This view has the following logic, which displays different text depending on whether the current user is registered:

<% if (Request.IsAuthenticated) { %> Welcome <b><%= Html.Encode(Page.User.Identity.Name) %></b>! [ <%= Html.ActionLink("Logout", "Logout", "Account") %> ] <% } else { %> [ <%= Html.ActionLink("Login", "Login", "Account") %> ] <% } %> 
+8
source

All Articles