john
john

Reputation: 43

authentication and authorization in mvc5

i'm using mvc5 with default authentication and authorization by create individual User Account in visual studio 2013.But i have a problem. in path "/View/Shared/_LoginPartial.cshtml" have code follow:

@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
    using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
    {
    @Html.AntiForgeryToken()

    <ul class="nav navbar-nav navbar-right">
        <li>
            @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })
        </li>
        <li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
    </ul>
    }
}
else
{
    <ul class="nav navbar-nav navbar-right">
        <li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
        <li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
    </ul>
}

i'm try create a account for first project and login successful. after, i create second project and run and i don't login but second project display login successful. i'm checked Request.IsAuthenticated=true. why i don't login but the second project display login successful. Sory, my bad english

Upvotes: 1

Views: 105

Answers (1)

Aladein
Aladein

Reputation: 312

i think if you use code and make Session its well be butter:

code :

Session("Admin") = "AdminLoginn" Session.Timeout = 120

this code in login page

and you must check code in next page : If Session("Admin") <> "AdminLoginn" Then Response.Redirect("AdminLogin.aspx", False) Exit Sub End If

thanx

Upvotes: 1

Related Questions