Using http header to send file

Here's how you can make use of http header response to send a file direct to the clients browser for download.

 

    Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click

        Response.ContentType = "application/x-unknown"

        Response.AddHeader("Content-Disposition", "attachment; filename=test.txt")

        Response.WriteFile("test.txt")

        Response.End()

        Response.Clear()

 

    End Sub

2 Comments

Comments have been disabled for this content.