在 PHP 中,我可以执行以下操作: header("Content-type: application/octet-stream")
然后下载我输出的任何内容,而不是在浏览器中显示。
ASP中有类似的方法吗?我已经看到了所有使用 ADODB.Stream 的文件流等,但这似乎对我不起作用,并且总是需要另一个文件来加载内容。
我是个 ASP 菜鸟,所以对我宽容一些。 :p 我想做的就是有一个输出 CSV 的脚本,它将强制下载而不是在浏览器中显示。
谢谢
编辑
这是我当前的脚本:
reportingForce.aspx.vb
Public Class reportingForce
Inherits System.Web.UI.Page
Dim FStream
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Buffer = True
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-disposition", "attachment; filename=" & Chr(34) & "my output file.csv" & Chr(34))
Response.Write("1,2,3,4,5" & vbCrLf)
Response.Write("5,6,7,8,9" & vbCrLf)
End Sub
End Class
reportingForce.aspx
Hello,World
最佳答案
您可以使用:
Response.ContentType =“应用程序/八位字节流”
关于asp.net - ASP强制下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5065930/