Sending File from Server to WebClient via Response

Discussion in 'ASP .Net' started by Lars Netzel, Nov 7, 2005.

  1. Lars Netzel

    Lars Netzel Guest

    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
     
    Lars Netzel, Nov 7, 2005
    #1
    1. Advertisements

  2. Lars Netzel

    Patrice Guest

    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
     
    Patrice, Nov 7, 2005
    #2
    1. Advertisements

  3. Lars Netzel

    Lars Netzel Guest

    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
     
    Lars Netzel, Nov 7, 2005
    #3
  4. Lars Netzel

    Prakash Guest

    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.
     
    Prakash, Nov 7, 2005
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.