Save dialog box to download file, Saving file from ASP.NET server to the client(保存对话框以下载文件,将文件从 ASP.NET 服务器保存到客户端)
问题描述
我一直在互联网上搜索,但找不到任何有用的答案.
I've been searching around the internet, but couldn't find any useful answer.
我有一个 ASP.NET 网站,它部署在服务器上.服务器上的 ASP.NET 网站可以访问名为 W:/的目录.公司的客户可以访问该网站.该网站在 ListBox 中列出了 W:/目录中的所有 PDF 文件.客户端应该能够从列表框中选择 PDF 文件,并通过为其选择位置将它们保存到本地 PC.
I have an ASP.NET web site, which is deployed on server. The ASP.NET web site on the server can access a directory called W:/ . The clients in the company can access the web site. The web site lists in a ListBox all the PDF files from the W:/ directory. The client should be able to select PDF files from the listbox and save them to it's local PC by selecting a location for it.
类似于在网页上另存为文件.
Something like save as file on web pages.
您能否提供一些解决方案或解决方法?
Could you provide me some solution or work around ?
推荐答案
终于找到一篇文章,提示保存对话框从 ASP.NET 下载文件
Finally I've found an article, which Prompts a Save Dialog Box to Download a File from ASP.NET
我把它贴在这里,也可以帮助其他人并节省一些时间.
I post it here, might help somebody else as well and save some time.
String FileName = "FileName.txt";
String FilePath = "C:/...."; //Replace this
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
response.TransmitFile(FilePath);
response.Flush();
response.End();
这篇关于保存对话框以下载文件,将文件从 ASP.NET 服务器保存到客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:保存对话框以下载文件,将文件从 ASP.NET 服务器保存到客户端
基础教程推荐
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01