【发布时间】:2015-01-07 12:15:05
【问题描述】:
我是法国人,抱歉我的英语不好。
我有一个为我生成文件的慢速 ASP.NET 方法:
public ActionResult Method([Bind(Prefix = "Id")] Guid id)
{
//Long work
return File(data, "application/pdf", doc.Name + ".pdf");
}
在我的 cshtml 文件中有一个按钮(我使用 Razor):
<a title="Télécharger" onclick="DownloadFile('@entity.Id')"/>
还有脚本方法:
<script>
function DownloadFile(id) {
var url = '@Url.Action("Method", "TheController", new { id = "Id" })'.replace('Id', id);
$("#divLoading").show();
$.post(url, null,
function (data) {
$("#divLoading").hide();
});
}
</script>
div 加载:
<div id="divLoading" style="margin: 0px; padding: 0px; position: fixed; right: 0px;
top: 0px; width: 100%; height: 100%; background-color: #666666; z-index: 30001;
opacity: .8; filter: alpha(opacity=70);display:none" >
<p style="position: absolute; top: 30%; left: 45%; color: White;">
Génération du document...<img src="../../Content/img/ajax-loader.gif">
</p>
</div>
调用了C#方法,divLoading出现又消失,但是导航器没有下载文件。
如果我写: 这是工作。 但是装载机不存在。我想要。
我的问题不是如何在下载文件时制作加载器,而是只在下载开始之前显示加载器。
谢谢。
【问题讨论】:
标签: jquery asp.net razor download loader