I am using a MVC4 database with Simple membership. In the sample template
they use the following:
@if (Request.IsAuthenticated) {
<text>
Hello, @Html.ActionLink(User.Identity.Name, "Manage", "Account", routeValues: null, htmlAttributes: new { @class = "username", title = "Manage" })!
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) {
@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}
On other sites I see this:
@if(WebSecurity.IsAuthenticated)
{
<p>Welcome, @WebSecurity.CurrentUserName</p>
<p><a href="@Href("~/logout")">Log out</a></p>
}
Can someone tell me what is the difference between these?
Request.IsAuthenticated
I believe that if you are using the Windows authentication. If the request is send by an authenticated user, this will always true. In this the user and groups etc are handled by Windows Active Directory or User accounts in your machine.
WebSecurwity.IsAuthenticated
This I believe that while using Membership provider, we can able to CRUD operations for users.
Please visit the below url to obtain more info.
http://www.mikepope.com/blog/displayblog.aspx?permalink=2240