Frage

Im trying to log out of a page and have it redirect back to the home page but it cant seem to itself out of the area.

<div class="container">
<div class="pull-right">
<div class="span12">
@using (Html.BeginForm("LogOff", "Account", new { area = ""}, FormMethod.Post, new { id = "logoutForm" }))
{
   @Html.AntiForgeryToken()
   <text>
  Hello, @Html.ActionLink(User.Identity.Name, "Manage", "Account", htmlAttributes: new { @class = "username", title = "Manage" })!    |     <a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
  </text>
}
</div>
</div>
</div>

This above is the _LoginPartial.cshtml.
when you log in it sends you to a member area then when you hit log off the url changes to /member/account/logoff which looks like its trying to find the account controller in the member area to invoke actionresult of logoff but the account controller is in the root of the project where it was originally created in.

War es hilfreich?

Lösung 2

I figured it out, I was using the wrong constructor. I needed to put null as a parameter at the end to use the correct constructor

Andere Tipps

That syntax looks correct. Is AccountController in a separate area than the default main area? You can also give this a try - https://t4mvc.codeplex.com/documentation. You can look at how Html.BeginForm is specified in that. The strong typing helps you avoid typos and mistakes.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top