exception sending file through web service

L

Luismi

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?
 

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

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top