none
Force download

    Question

  • Hi,

    I'm trying to force a download from a file.

    The code below works fine, for a file on the hard disk. Problem is that the files are stored in WSS (in a SQL database).

    Currently I'm using this code:

    string currentURL = Request.QueryString["filename"].ToString();
    string filename = currentURL.Substring(Request.ApplicationPath.Length).TrimStart('/');

    Response.TransmitFile(currentURL);
    Response.Write(currentURL);

    HttpRequest request = new HttpRequest(currentURL);
    byte[] buffer = request.BinaryRead(request.TotalBytes);
    Response.Write(buffer.Length);
    if (buffer.Length > 0)
    {
      Response.BinaryWrite( buffer );
    }

    Response.AddHeader( "content-disposition","attachment; filename=" + filename);

    The highlighted line, I used to check the size of the document I need to retrieve
    When I run this, it gives a length of 0.
    Therefore I'm thinking that the windows authentication used in wss has something to do with it.
    Anyone who knows how I can make this request, and write the response to the client?

    Thanks!



     

     

    Friday, February 10, 2006 7:22 PM