这里是我的控制器代码:是否可以使用ajax.beginform下载文件?或ajax?
[HttpPost]
public async Task<ActionResult> DownloadItemList(int subcampaignId, string SheetName, string filename)
{
DataSet ds = new DataSet();
string url = string.Format("api/report/subcampaign/{0}", subcampaignId);
var response = await req.GetXMLAsync(url);
XmlDocument xmlDoc = new XmlDocument();
try
{
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
xmlDoc.PreserveWhitespace = true;
xmlDoc.LoadXml(content);
XmlNodeReader xmlReader = new XmlNodeReader(xmlDoc);
ds.ReadXml(xmlReader);
}
IDataTableToWorkbookUtility workbookExportUtility = new DataTableToWorkbookUtility();
byte[] excelContent = workbookExportUtility
.ExportDataTableToWorkbook(ds.Tables[0], SheetName)
.GetBytes();
return this.File(excelContent, "application/vnd.ms-excel", filename + ".xls");
}
catch (Exception e)
{
log.Debug("CampaignListController/GetAudio: " + e.Message);
throw;
}
}
当我使用ajax.beginform ..而不是下载文件,响应阅读文本。我想用阿贾克斯,因为我想显示一个加载栏,当使用点击提交按钮..我想要做的是显示加载状态,同时等待文件被下载
嗨,我可以在哪里得到“dowload_path”?你能更详细地告诉我吗?谢谢! – kxko