Return XML from aspx

 
Post new topic   Reply to topic    Aprelium Forum Index -> ASP.NET
View previous topic :: View next topic  
Author Message
mirror222
-


Joined: 04 Jun 2014
Posts: 1

PostPosted: Wed Jun 04, 2014 9:07 am    Post subject: Return XML from aspx Reply with quote

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!
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> ASP.NET All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group