D.B
D.B

Reputation: 4289

Html.BeginForm to call an action not in an Area?

How can I use Html.BeginForm to link from within an area to an action and controller not in an area? I am using:

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

When I click the button it is looking for the controller in the area but it is not there.

Appreciate any suggestion.

Upvotes: 0

Views: 1513

Answers (2)

D.B
D.B

Reputation: 4289

Thanks on helpful comments, The solution is:

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

Upvotes: 1

DLeh
DLeh

Reputation: 24395

Try explicitly providing null or empty string "" as the area:

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

Upvotes: 0

Related Questions