我正在使用 jquery 文件上传器(每个 blueimp),我想知道如何将回发定向到 index.cshtml 以外的特定 http 回发(默认情况下,post 将发送到 index.cshtml)?
例如,当调用 Home/Bulk...然后选择文件后,回发默认为 [httppost]index.cshtml()...如何将其定向到 [httppost]bulk.cshtml()?谢谢!
查看(批量.cshtml):
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="@Url.Content("~/Scripts/jquery.ui.widget.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.iframe-transport.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.fileupload.js")" type="text/javascript"></script>
@using (Html.BeginForm("Bulk", "Home")) // I want this to direct back to httppost:bulk handler
{
<input id="fileupload" type="file" name="files" multiple="multiple"/>
}
控制器:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(IEnumerable<HttpPostedFileBase> files)
{
foreach (var file in files)
{
var filename = Path.Combine(Server.MapPath("~/App_Data"), file.FileName);
file.SaveAs(filename);
}
return View();
}
public ActionResult Bulk()
{
return View();
}
[HttpPost]
public ActionResult Bulk(IEnumerable<HttpPostedFileBase> files)
{
foreach (var file in files)
{
var filename = Path.Combine(Server.MapPath("~/App_Data"), file.FileName);
file.SaveAs(filename);
}
return View();
}
}