Entire web page source code appended to end of XML document

Go To StackoverFlow.com

0

I have a C# ASP webpage that is creating a KML document, and it's working fine. It's generating all the locations properly. The problem is that, as it generates the file, it appends the entire web source code to the file.

Below is the beginning of the code that generates the file, and I'm guessing the problem is somewhere there.

context.Response.ContentType = "application/vnd.google-earth.kml+xml";
context.Response.AddHeader("Content-Disposition", "attachment;      
filename=Results.kml");          
XmlTextWriter kml = new XmlTextWriter(context.Response.OutputStream,  System.Text.Encoding.UTF8);          
kml.Formatting = Formatting.Indented;         kml.Indentation = 3;              
kml.WriteStartDocument(); 

Thank you for your help.

2012-04-04 18:22
by A.J. Myers
Incorrectly tagged. This is not asp-classic. (I've removed that tag). It may be ASPNET; if so, you should add that tag, and in general you may wish to verify and clarify what you are asking about here. Also I'd suggest that you include more of the code of the app that is showing the problem. Not just the XML-generation part; the problem may be elsewhere - Cheeso 2012-04-04 18:25
My apologies on the tag marking, I didn't even think to specify one specific type of ASP so I just marked 'ASP'. That being said Joric was able to answer my question with what I provided, and I would normally post more but the code I'm working with wasn't readily available without rewriting it all, which is something I hoped I'd be able to avoid - A.J. Myers 2012-04-04 18:31


1

You need to close response stream after document is written there. It can be done by calling Response.CompleteRequest()

2012-04-04 18:25
by the_joric
Ads