How do I get the LoginStatus for ASP.Net MVC? I can connect and authenticate on MVC, but I am not sure how to get the LoginStatus, can anyone help?
When you create a new MVC project, the csproj template creates a partial view called "LoginUserControl", located at ~/Views/Shared/LoginUserControl.ascx.
This view has the following logic, which renders different text depending on whether or not the current user is logged in:
<%
if (Request.IsAuthenticated) {
%>
Welcome <b><%= Html.Encode(Page.User.Identity.Name) %></b>!
[ <%= Html.ActionLink("Logout", "Logout", "Account") %> ]
<%
}
else {
%>
[ <%= Html.ActionLink("Login", "Login", "Account") %> ]
<%
}
%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With