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. Advertising

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:
    881
    Dag Sunde
    Jun 1, 2006
  2. John Abel

    Sending Through ^] Through telnetlib

    John Abel, Jan 23, 2004, in forum: Python
    Replies:
    2
    Views:
    377
  3. Mahrt, Dallas

    RE: Sending Through ^] Through telnetlib

    Mahrt, Dallas, Jan 23, 2004, in forum: Python
    Replies:
    0
    Views:
    536
    Mahrt, Dallas
    Jan 23, 2004
  4. prowyh
    Replies:
    0
    Views:
    324
    prowyh
    Nov 16, 2007
  5. Leo Violette
    Replies:
    0
    Views:
    1,088
    Leo Violette
    Apr 17, 2009
Loading...

Share This Page