我有一个允许用户提交文件的部分视图。
<form action="Attachments" method="post" enctype="multipart/form-data" target="_self">
<div>
<label style="text-align: left;">Add File:</label>
</div>
<div>
<input type="file" name="file" id="file" style="width: 275px;" />
</div>
<div style="text-align: right;">
<input type="submit" value="Add"/>
</div>
</form>
这将调用 HTTPPost 的 AttachmentsController 方法
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
if (file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine("C:\\Attachments", fileName);
file.SaveAs(path);
return AddAttachment(fileName);
}
return RedirectToAction("Failed", "Attachments");
}
addAttachment 返回 "return RedirectToAction("Index", "Attachments");" 在完成所有这些以添加附件之后,整个屏幕都被刷新了,我只想刷新用于添加附件的部分视图。我怎么能做到这一点!?