Im getting this error
<b> Exception Details: </b>System.Web.Mvc.HttpAntiForgeryException: The required anti-forgery form field "__RequestVerificationToken" is not present.<br><br>
Im using typeahead.js to autocomplete in a text box, but the action method on the controller never gets hit. Ive also used the typeahead.js for mvc 5 models helper. Heres my markup in the view
@Html.AutocompleteFor(model => model.NewUser.End_User_Org, model => model.NewUser.End_User_Org, "GetOrganisations", "User", false, new { htmlAttributes = new { @class = "form-control" } })
this is inside a form where ive declared
@Html.AntiForgeryToken()
and my controller action
[HttpGet]
[ActionName("GetOrganisations")]
[ValidateAntiForgeryToken]
public ActionResult Get(string search)
{
JsonResult result = new JsonResult();
if (!string.IsNullOrEmpty(search))
{
GetOrganisationRequestNonPrimary request = new GetOrganisationRequestNonPrimary(search);
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
var organisations = this._organisationService.OrganisationAutoComplete(request);
result.Data = organisations.Organisations.AsQueryable();
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
}
return result;
}
at runtime Ive checked the html and I have this
<form id="userForm" class="form-horizontal" method="post" style="" role="form" novalidate="novalidate">
<input name="__RequestVerificationToken" value="actual value here..." type="hidden">
so the antiforgery token is present but why isnt it being sent to the controller action ? Is this a known issue with Typeahead.js and the mvc5 model helpers ?