【问题标题】:Save As Dialog box in asp.netasp.net 中的另存为对话框
【发布时间】:2015-01-08 20:02:03
【问题描述】:

我有网络应用程序(asp.net)。当用户单击下载按钮时,有没有办法显示“另存为对话框”(在浏览器中)。我尝试了几个代码,但没有得到预期的结果.all是正常下载文件到下载(浏览器默认下载路径)。是否可以在网络浏览器中打开另存为对话框

【问题讨论】:

  • 这完全不可能。
  • 浏览器用户界面属于用户,不属于Web开发者。如果用户告诉浏览器显示另存为对话框怎么办?
  • 这个概念并非不可能——显然你无法打开系统的文件对话框,可能有办法告诉浏览器文件已准备好下载。这将打开浏览器的文件对话框。

标签: c# asp.net browser savefiledialog


【解决方案1】:

【讨论】:

  • 嗨,我已经尝试过这段代码。我在 response.Flush() 上遇到异常; “[System.Threading.ThreadAbortException] = {无法评估表达式,因为代码已优化或本机框架位于调用堆栈顶部。}”并且文件在没有打开另存为对话框的情况下正常下载
【解决方案2】:

您可能正在寻找下载 asp.net 中的文件? 请参阅下面的示例。

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=MyFile.pdf");
Response.TransmitFile(Server.MapPath("~/Files/MyFile.pdf"));
Response.End();
.htm, .html     Response.ContentType = "text/HTML";
.txt    Response.ContentType = "text/plain";
.doc, .rtf, .docx    Response.ContentType = "Application/msword";
.xls, .xlsx    Response.ContentType = "Application/x-msexcel";
.jpg, .jpeg    Response.ContentType = "image/jpeg";
.gif    Response.ContentType =  "image/GIF";
.pdf    Response.ContentType = "application/pdf";

How to download a file in ASP.Net

【讨论】:

  • 不确定该帖子在当前状态下是否甚至是有效评论。如果您认为文章显示了问题的答案,请提供内嵌链接的摘要。
  • 我会提供详细信息。我稍后会编辑我的帖子。必须先吃个快餐;)...谢谢你提醒我:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多