Download ASP Force

In PHP, I can do: header("Content-type: application/octet-stream")and then everything that I output is loaded, not displayed in the browser.

Is there a similar way to do this in ASP? I saw about all file streams and such using ADODB.Stream, but this does not work for me and always requires another file to download content.

A bit of ASP noob, so it's easy on me .: p All I want to do is have a script that outputs CSV and that will force download, not show in browser.

thank

EDIT

here is my script now:

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
+3
source share
3 answers

You can use:

Response.ContentType = "application / octet-stream"

+1
source

- "Content-disposition" "attachment". .

, - ASP:

Response.AddHeader "content-disposition","attachment; filename=whatever.csv"

0

I would do both.

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
0
source

Source: https://habr.com/ru/post/1793588/


All Articles