Sending File from Server to WebClient via Response

L

Lars Netzel

I want to press a Linkbutton (in a DatagridItem) and return a file that is
not shared in the IIS. I want to disallow "deeplinking".

The following code works fine (it sends the file I want) but I want it to be
parallel to the webpage, not replacing the page with the datagrid.. how do I
force the file download to a new window?


Public Sub SendFile(ByVal Filepath As String)
Response.Clear()

Response.ContentType = "octet/stream"

Response.AddHeader("Content-Disposition", "outline;
filename=filetosend.mp3")

Response.Flush()

Response.WriteFile(Filepath)

Response.Flush()

End Sub

Best Regards

/Lars
 
P

Patrice

My understanding is that if the browser sees that this is not a content he
should processed, the current windows is left intact.

What is the "outline" content-disposition ? (I'm using "attachment" to force
a file download). Aslo you could try wihtout the content-type that is likely
not needed in this cotnext...

Let us know
 
L

Lars Netzel

Hi... the Outline was something that I got in another example have no idea
what it is... and when changing that to Attachment it work exactly like I
wanted:) thank you!

So now..

Response.Clear()

Response.ContentType = "octet/stream"

Response.AddHeader("Content-Disposition", "attachment; filename=file.mp3")

Response.Flush()

Response.WriteFile(Filepath)

Response.Flush()


/Lars
 
P

Prakash

i too uses this method to send file from server to client is it possible to
send multiple files, i have tried but couldn't do that.Is there any method
to do it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top