gpt4 book ai didi

asp.net - 在 ASP.NET 中下载文件而不弹出窗口

转载 作者:行者123 更新时间:2023-12-02 17:52:18 26 4
gpt4 key购买 nike

我正在使用代码下载文件

btnDownloadTemplate.Attributes.Add( "onClick", "window.open('StudyReport/WordReportTemplate.doc', 'OpenTemplate', 'resizable=no,scrollbars=no,toolbar=no,directories=no,status=no,menubar=no,copyhistory=no');return false;" );

这将显示一个弹出窗口并显示下载对话框。如何避免弹出窗口并且屏幕上仅显示下载对话框?

最佳答案

我得到了答案。我删除了属性并在其中添加了单击事件 和 。

    string path = Server.MapPath("");
path = path + @"\StudyReport\WordReportTemplate.doc";
string name = Path.GetFileName( path );
Response.AppendHeader( "content-disposition", "attachment; filename=" + name );
Response.ContentType = "Application/msword";
Response.WriteFile( path );
Response.End();

关于asp.net - 在 ASP.NET 中下载文件而不弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/986075/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com