Search code examples
c#asp.netasp.net-mvchttp-postantiforgerytoken

Resource could not be found asp.net mvc


I am familiarizing myself with asp.net mvc, Identity and trying a simple log off but get The resource cannot be found.

in my html page

<li><a href="@Url.Action("LogOff", "Account")" id="home">Log off</a></li>

and this is in the AccountController

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult LogOff()
    {
        AuthenticationManager.SignOut();
        return RedirectToAction("Index", "Home");
    }

and this in my route config file

 routes.MapRoute(
         null,
         "LogOff",
         new { controller = "Account", action = "LogOff" }

What could I be missing?


Solution

  • simply putting by removing HttpPost

    public ActionResult LogOff()
    {
        AuthenticationManager.SignOut();
        return RedirectToAction("Index", "Home");
    }
    

    works for me