【发布时间】:2011-08-12 07:49:25
【问题描述】:
我在 asp.net 中的应用程序使用 vb.net 脚本生成一个带有系统处理输出的文件,响应按钮单击。该文件存储在服务器的一个文件夹中,我想为用户自动开始下载该文件。我该怎么做?
【问题讨论】:
标签: vb.net asp.net-ajax
我在 asp.net 中的应用程序使用 vb.net 脚本生成一个带有系统处理输出的文件,响应按钮单击。该文件存储在服务器的一个文件夹中,我想为用户自动开始下载该文件。我该怎么做?
【问题讨论】:
标签: vb.net asp.net-ajax
以下代码将向用户显示标准的“另存为..”对话框。您需要将内容类型更改为文件的 mime。
Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=yourfile.jpg");
Response.TransmitFile( Server.MapPath("~/yourfile.jpg") );
Response.End();
【讨论】: