MVC5 communication failure from different areas

I have an MVC5 application with several different areas. The project was created using the "Disable" link in the navigation bar, but if the user is in any of the areas, the link does not work. I thought adding:

new { area = "" } 

will return the link to the right place, but either it’s not, or I tried it in the wrong place. Code as below:

  @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("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li> </ul> } 

Any ideas on what needs to be changed in order to work with the journal, no matter what area the user is in?

+7
asp.net-mvc asp.net-mvc-5 asp.net-identity asp.net-mvc-areas
source share
1 answer

The correct place is within the parameters of Html.BeginForm(...) :

 using (Html.BeginForm("LogOff", "Account", new { area = "" }, FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" })) 
+12
source share

All Articles