【发布时间】:2014-03-30 10:56:42
【问题描述】:
我有一个允许用户提交文件的局部视图。
<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");" 在完成所有这些以添加附件之后,整个屏幕都被刷新了,我只想刷新用于添加附件的部分视图。我怎样才能做到这一点!?
【问题讨论】:
标签: asp.net-mvc partial-views ajax-forms