Generate new token on each request in MVC Ajax post call (Custom Code) Step: 1 In controller add below Code to generate new random token and store it in the session protected string GenerateCSRFToken() { RandomNumberGenerator rng = new RNGCryptoServiceProvider ( "Add Your Salt String" ); var tokenData = new byte [64]; rng.GetBytes(tokenData); var token = Convert .ToBase64String(tokenData); Session[ "CSRFtoken" ] = token.Trim(); return token; } Step: 2 In controller generate new token and pass it to view using ViewData. public ActionResult Index() { ViewData[ "CSRFtoken" ] = GenerateCSRFToken(); return View(); } Step: 3 In View create hidden field and assign ViewData value to it. < input type ="hidden" value =" @ ViewData[ "CSRFtoken" ] " id ="hdnCSRFtoken" /> Step: 4 In View read and pass the hidden field value as method parameter/