Problem sending file to the client

G

Guest

Hi all

In a web user control I have a linkbutton, when the user clicks on it I
retrieve some object from a web service, this object’s class was created
using xsd.exe. I serialize the object using an XmlSerializer and the
resulting string is effectively the XML I want. It is stored in “restultâ€, I
wrote the following code to send the xml to the client as a download file
dialog:

Page.Response.Clear();
Page.Response.ContentType = "text/xml";
Page.Response.AppendHeader("Content-Disposition",
"attachment;filename=Test.xml");
Page.Response.ContentEncoding = System.Text.Encoding.UTF8;
Page.Response.Output.Write(restult);
Page.Response.Flush();

The client successfully sees the file download dialog box, but the result is
not only the XML, it also has all HTML of the page and the user control
appended to the value of result!

How can I avoid that?
Any link to read about?
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top