mirror222 -
Joined: 04 Jun 2014 Posts: 1
|
Posted: Wed Jun 04, 2014 9:07 am Post subject: Return XML from aspx |
|
|
I tried to write xml content(UTF-8 format) from an aspx script.
It works perfectly with ASP.NET Development Server, however I got this message in the Abyss Web Server X1 (v 2.9.0.1).
Quote: | This page contains the following errors:
error on line 2 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.
|
Screenshots:
Here is the source I used:
Code: | public static void ResponseXML(HttpResponse response, int statuscode, string desc)
{
XmlDocument doc = new XmlDocument();
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(dec);
XmlElement root = doc.CreateElement("XML");
root.SetAttribute("Version", "1.0");
doc.AppendChild(root);
XmlElement xmlcode = doc.CreateElement("Code");
xmlcode.InnerText = statuscode.ToString();
root.AppendChild(xmlcode);
XmlElement xmldesc = doc.CreateElement("Desc");
xmldesc.InnerText = desc;
root.AppendChild(xmldesc);
response.StatusCode = statuscode;
response.Clear();
response.ContentType = "text/xml; charset=utf-8";
response.Write(doc.OuterXml);
response.End();
} |
Is there any specific configuration to make it work? Your reply will Highly appreciated.
Thank you! |
|