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

RBSAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kblauCommented:
tried this.  got same result as you and found best fix w/o having to change your architecture, but would probably change architecture to put ALL of account information in one place, either the area or outside the area, and not split it up.

I created my view and it called a shared partial (this same shared partial was called from my area).
I clicked on logout and it worked.
I clicked on a link to call the area page and while in the area page view, click on logout and it got not found error like you had.

To resolve, I changed my controller name in my view in my area to call "AccountInArea" controller, after copying Account controller outside area to this new controller.

Let me know if you have any questions.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RBSAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.