Link to home
Start Free TrialLog in
Avatar of RBS
RBS

asked on

MVC Logout not working when using Areas

Hi:

I have a standard MVC application in which I have incorporated the boiler plate partial in the Navigation bar.  
@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() + "!", "Index", "Manage", 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>
}

Open in new window


I then created a new Area for Admin and created a new Admin Layout in that area.  The Navbar for the layout in the new area references the original Login Partial.  All works fine unless I try to log out froma page in  the Admin Area in which case I get the following error:

 
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /Admin/Account/LogOff

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kblau
kblau

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RBS
RBS

ASKER

Thanks