ASP Force Download
Posted
by
Thomas Clayson
on Stack Overflow
See other posts from Stack Overflow
or by Thomas Clayson
Published on 2011-02-21T12:30:38Z
Indexed on
2011/02/21
15:25 UTC
Read the original article
Hit count: 242
In PHP I can do: header("Content-type: application/octet-stream")
and then anything that I output is downloaded instead of showing in the browser.
Is there a similar way to do this in ASP? I have seen about all the file streaming and such using ADODB.Stream, but that doesn't seem to work for me and always requires another file to load the content from.
Bit of an ASP noob, so go easy on me. :p All I want to do is have a script that outputs a CSV and that will force download instead of showing in the browser.
Thanks
EDIT
here is my script currently:
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
© Stack Overflow or respective owner