user2206329
user2206329

Reputation: 2842

how to not specify an area for a form in MVC 4

I have an MVC application where it has areas configured. The logout link appears in the layout page so it is displayed on every page. When I click the logout it always appends it with whereever the area it was in...

I just want it to go to Account\logout - no area

I tried the following but it didn't work... any suggestions?

@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", area="" }))
{
   @Html.AntiForgeryToken()
   <a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}

Upvotes: 3

Views: 784

Answers (1)

Bhushan Firake
Bhushan Firake

Reputation: 9448

You are using a different overload. I think you should do that as below:

@using (Html.BeginForm("LogOff", "Account", new { area = ""}, FormMethod.Post, new { id = "logoutForm" }))
{
  @Html.AntiForgeryToken()
  <a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}

Upvotes: 3

Related Questions