I'm passing anti-forgery token still getting, The required anti-forgery form field __RequestVerificationToken is not present error.
Here is my form
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "create" }))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
..............
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input id="submit" type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
And here is my ajax call
$(function () {
$("#submit").click(function (event) {
event.preventDefault();
var form = $('#create');
var token = $('input[name="__RequestVerificationToken"]', form).val();
$.ajax({
type: "POST",
url: "/Create/Index",
data:{
__RequestVerificationToken: token,
Title: $("#Title").val(),
Description: $("#Description").val()
},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
});
});
I don't have requireSSL true in web.config as this post says https://stackoverflow.com/a/28786181/2238873
Where I'm doing wrong, please help me.