I have ajax request that sends data to my controller , it collects value of my dropdown
the error is
POST http://localhost:65070/form/create 500 (Internal Server Error)
response of error is
The required anti-forgery form field "__RequestVerificationToken" is not present.
UPDATE
My Form
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
Form
@Html.LabelFor(model => model.FormName)
@Html.EditorFor(model => model.FormName)
@Html.ValidationMessageFor(model => model.FormName)
@Html.LabelFor(model => model.MasterID, "MasterModule")
@Html.DropDownList("MasterID", String.Empty)
@Html.ValidationMessageFor(model => model.MasterID)
}
My ajax Request
$('#State').change(function () {
var a = $('#State').val();
$.ajax({
url: "/form/create",
type: "POST",
data: { 'SubID': a },
success: function (result) {
// console.log(result);
}
});
});
My controller
public ActionResult Create(Form form, int SubID)
{
if (ModelState.IsValid)
{
form.SubId =SubID;
form.CreatedDate = DateTime.Now;
form.CreatedBy = 1;
form.CreatedDate = DateTime.Now;
form.IsActive = true;
form.ModifyBy = 1;
form.ModifyDate = DateTime.Now;
db.Forms.Add(form);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.MasterID = new SelectList(db.Departments, "MasterId", "ModuleName", form.MasterID);
return View(form);
}
It is giving 500 internal error.. its awkward plz help