exception sending file through web service

Discussion in 'ASP .Net Web Services' started by Luismi, Jun 6, 2006.

  1. Luismi

    Luismi Guest

    Hi everybody,

    I've got a problem with a Web Service. I Call a method that must binary
    send a file to the Internet Explorer but the code generates an exception
    when I send the file. Here is the code:

    Dim Content(-1) As Byte
    Dim File As IO.FileStream =
    IO.File.Open(Context.Request.ServerVariables("APPL_PHYSICAL_PATH") &
    "test2.txt", IO.FileMode.Open)
    ReDim Contenido(File.Length)
    File.Read(Content, 0, File.Length)
    File.Close()
    Context.Response.Buffer = True
    Context.Response.AddHeader("Content-Disposition",
    "attachment;filename=test2.txt")
    Context.Response.ContentType = ""
    Context.Response.BinaryWrite(Content)

    The code breaks in the line "Context.Response.BinaryWrite(Content)"
    throwing the next exception:

    The data at the root level is invalid. Line 1, position 1.

    Can someone help me?
     
    Luismi, Jun 6, 2006
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Digital Puer
    Replies:
    1
    Views:
    1,023
    Dag Sunde
    Jun 1, 2006
  2. John Abel

    Sending Through ^] Through telnetlib

    John Abel, Jan 23, 2004, in forum: Python
    Replies:
    2
    Views:
    538
  3. prowyh
    Replies:
    0
    Views:
    424
    prowyh
    Nov 16, 2007
  4. rtc

    Download file through Web Service???

    rtc, Jul 25, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    372
  5. Kamesh

    sending a PDF file from a .NET web service - urgent

    Kamesh, Dec 3, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    517
    Dan Rogers
    Dec 3, 2004
  6. Jon

    sending an xml file over a web service

    Jon, Nov 17, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    757
    John Saunders
    Nov 18, 2006
  7. Leo Violette
    Replies:
    0
    Views:
    1,318
    Leo Violette
    Apr 17, 2009
  8. Saurabh
    Replies:
    3
    Views:
    149
    Saurabh
    Sep 30, 2006
Loading...