asp.net mvc - MVC "LogOut" controller causes "The resource cannot be found." error when using "ValidateAntiForgeryToken" attribute -
When I add the "ValidateAntiForgeryToken" attribute to my LoggOff controller, it does not map to my controller and can not be "resource Got it. " Error. What's the problem? Here's my controller:
  // POST [httpOOST] [legitimate antiforrhitine] public action logog logoff () {authentication manager. Signature (); Redirect Action ("Index", "Home"); }    This is my view:  
  @ Microsoft.AspNet.Identity @ (Request.IsAuthenticated) {using (Html.BeginForm ("LogOff "," Account ", FormMethod.Post, new {id =" __RequestVerificationToken ", @class =" navbar-right "})) {@ Html.AntiForgeryToken () & lt; Ul class = "nav navbar-nav navbar-right" & gt; & Lt; Li & gt; @html.exeNlink ("User:" + UserEidentity.NETAARNAM (), "Management", "Account", Root Value: blank, HTMLAttives: New {title = "Management"}) & lt; / li & gt; & Lt; Li & gt; @HTMLconnect ("log off", "log off", "account") & lt; / li & gt; & Lt; / Ul & gt; }} And {& lt; Ul class = "nav navbar-nav navbar-right" & gt; & Lt; Li & gt; @HTMLconnect ("register", "register", "account", root value: empty, html, elevates: new {id = "registerLink"}) & lt; / li & gt; & Lt; Li & gt; @HTMLconnected ("login", "login", "account", root value: empty, html elevates: new {id = "login link"}) & lt; / li & gt; & Lt; / Ul & gt; }     
  You are not posting form while logging off  < P> This line will create a GET request  
  & lt; Li & gt; @ html.ActionLink ("log off", "logoff", "account") & lt; / li & gt;    You can send a submit button such as  
  & lt; A href = "javascript: document.getElementById ('__ Request Verification'). Submit ()" & gt; Logout & lt; / A & gt;    
 
  
Comments
Post a Comment