Problem using XmlTextWriter with MemoryStreams
I am having trouble getting the memory stream and XML text script class to work correctly.
Context.Reponse.BufferOutput=true;
Context.Response.ContentType = "application/xml";
stmOutput = new MemoryStream();
Output = new XmlTextWriter(stmOutput, Encoding.ASCII);
Output.WriteStartDocument();
Output.WriteStartElement("MyTag");
Output.WriteEndElement();
Output.WriteEndDocument();
Output.Flush();
stmOutput.Flush();
Context.Response.OutputStream.Write(stmOutput.ToArray(),0,(int)stmOutput.Length-1);
Context.Response.OutputStream.Flush();
Output.Close();
This is done inside the ASHX file. When I run this, whatever gets out is
<? xml version = "1.0" encoding = "us-ascii"?> <MyTag /
Am I missing something with the answer or memory stream or XML text writer? I'm a bit lost because I am following a little tutorial on this, doing whatever it shows, but instead uses a memory stream and doesn't work ..
+2
source to share