Nach dem Hinzufügen der Referenz jquery.unobtrusive-ajax.js ist der Upload null
Wenn ich mich nicht beziehejquery.unobtrusive-ajax.js
Ich kann Anhang auf Post bekommen. Wenn ich es beziehe, gibt es mir null.
<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);
......
Wie geht man damit um?