如果我不推荐,jquery.unobtrusive-ajax.js
我可以在 Post 上获得附件。如果我引用它,它会给我空值。
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
@using (Ajax.BeginForm("Index", "ContactSubmission", new AjaxOptions{ InsertionMode = InsertionMode.Replace, HttpMethod = "POST", OnSuccess = "updateSuccess" },
new { enctype = "multipart/form-data",@class = "form-horizontal", role = "form" }))
{
///code here
}
[HttpPost]
public JsonResult Index(Contact contact)
{
if (ModelState.IsValid)
{
if (contact != null)
{
string attachment = string.Empty;
// HttpPostedFileBase Attachment
if (contact.Attachment != null) attachment = SaveFile(contact.Attachment);
......
如何处理?