locked
Problems with donwloading file from server RRS feed

  • Question

  • User55467566 posted

    I'm trying to download files from server but I allways receive that message from server could not be parsed. My files folder is on different disc and I'll rather not to use URI because I can't hardcode URL (application is distribured in several intranet servers).

    Here is my code

    Dim objSourceFileinfo As System.IO.FileInfo

    objSourceFileinfo =New System.IO.FileInfo(puna_putanja) ' this is path from database and contains path and name of file on D: disc

    If objSourceFileinfo.Exists Then                  

    With Me.Response                       

     .AddHeader("Content-Disposition", "attachment; filename=" & objSourceFileinfo.Name)

     .AddHeader("Content-Length", objSourceFileinfo.Length.ToString)

     .ContentType = mime_dokumenta ' mime is collected from database. in this case "application/pdf"

     .WriteFile(objSourceFileinfo.FullName)

    .Flush()

    .End()

    End With

     

    I stayed out of ideas what can cause this kind of error and probably it is something obvious. I allready lost half of day on this one :(

    Please help

    Monday, May 6, 2013 10:14 AM

All replies

  • User-861818263 posted

    "ASPNet or Iuser" user of IIS servser  does have access to remote localtion(UNC path)  ?

    path should be like  :- "\\server\d$\a.txt"

    Monday, May 6, 2013 10:26 AM
  • User-2005691517 posted

    Do a Response.Clear before setting the Response headers.

    Monday, May 6, 2013 10:27 AM
  • User-2005691517 posted

    Is this call an AJAX call? File download can only happen on a postback.

    Monday, May 6, 2013 10:34 AM
  • User55467566 posted

    Greetings PK,

     

    It is AJAX call and it triggers on postback. I manage it with triggers, but it's not the issue...

    Monday, May 6, 2013 10:43 AM
  • User55467566 posted

    Greetings PK,

     

    I cleared it before setting response headers but no luck... Problem must lays somewhere else...

    Monday, May 6, 2013 10:44 AM
  • User-2005691517 posted

    You cannot download a file on an AJAX call.

    Monday, May 6, 2013 11:03 AM
  • User55467566 posted

    Is there any work around that you know of?

     

    Monday, May 6, 2013 11:29 AM