我正在尝试将一些表单数据和文件发送到asp.net mvc控制器但是我收到错误(在浏览器控制台中无法加载资源:服务器响应状态为500(内部服务器错误))
我的代码Jquery
$("#AddclientSave1").click(function () {
alert("Handler for .click() called.");
$("#Loading").show();
setTimeout(3000);
var form = $(this).serialize();
var Dateofbirth = $('.hasDatepicker').val();
var fd = new FormData();
var inputs = $('#file');
$.each(inputs, function (obj, v) {
var file = v.files[0];
fd.append("doc", file);
});
alert(fd);
alert(Dateofbirth);
$.ajax({
type: "Post",
url: '@Url.Action("AddClient", "TEST")',
data: { formData: form, doc: fd, Dateofbirth: Dateofbirth },
cache: false,
contentType: false,
processData: false,
async: false,
success: function (data) {
if (data) {
$("#Loading").hide();
$(".AddclientN").empty();
$(".AddclientN").html(data);
}
}, error: function (xhr, status, error) {
$("#Loading").hide();
}
});
});
C#controller
[HttpPost]
public ActionResult AddClient(Clients formData, IEnumerable<HttpPostedFileBase> doc, DateTime Dateofbirth)
{
return View(new Clients());
}