I am reading a file from the user files that contains xml that I am processing in a Generic Handler and then passing to the client.
The problem I am having is when I pass the string of xml to the client. Its not in the proper format. It removes the root tag and "<xml 1.0>" tag entirely when looking at it through the client code.
I am looking for some code to preserve the xml string as is when it gets to the client.
I am reading the xml out of a file using System.IO on the server..
public void ProcessRequest(HttpContext context)
{
if (context.Request.Files.Count > 0)
{
string path = context.Server.MapPath("~/Temp");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
var file = context.Request.Files[0];
string fileName;
if (HttpContext.Current.Request.Browser.Browser.ToUpper() == "IE")
{
string[] files = file.FileName.Split(new char[] { '\\' });
fileName = files[files.Length - 1];
}
else
{
fileName = file.FileName;
}
string strFileName = fileName;
fileName = Path.Combine(path, fileName);
file.SaveAs(fileName);
string msg = File.ReadAllText(fileName);
File.Delete(fileName);
context.Response.Write(msg);
}
}
The xml always starts at "Gambardella..." For some reason it cannot read the beginning of the file when being send to the cient.
Here is an image of the sample xml..

The data is sent out of the handler fine but the client cuts off the top information. It looks like the plugin I am using is storing the (or getting) the data from an iframe. Could the iframe maybe be the culprit in cutting off the beginning xml??
The sample client code I am using is here
text/htmlinstead asapplication/xml, meaning the browser will attempt to show it as html.