简体   繁体   English

为@Url.Action 添加等待微调器(下载文件)

[英]Add wait spinner for @Url.Action (download file)

Using jQueryMobile I am downloading a file using @Url.Action and a FileStreamResult in the controller class.使用 jQueryMobile 我正在使用控制器类中的 @Url.Action 和 FileStreamResult 下载文件。

Controller Method控制器方法

public ActionResult DownloadPDF()
{
    var stream = myHandler.getFileStream("myfile.pdf");
    return File(stream, "application/pdf", "myfile.pdf"));
}

Html code html代码

<a href='@Url.Action("DownloadPDF", "Home">
    <div>
        <!-- HTML Content -->
    </div>
</a>

Works great!效果很好! But how may I know when the download is complete, to add a wait-spinner?但是我怎么知道下载什么时候完成,添加一个等待微调器?

I want to use the FileStreamResult as the file is not stored on the webserver (stored in db).我想使用 FileStreamResult,因为该文件未存储在网络服务器上(存储在 db 中)。

Is it possible to "know" when the file is downloaded by using Url.Action?使用 Url.Action 下载文件时是否可以“知道”?

It's not possible to do this, as the page does not know anything about the request (which technically is another page entirely).这是不可能的,因为页面对请求一无所知(从技术上讲,这完全是另一个页面)。

You can register that a user clicked on the link, but it is not possible to find any more information about the download request - whether it completed, cancelled or errored.您可以注册用户点击了链接,但无法找到有关下载请求的更多信息 - 无论下载请求是否完成、取消或错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM