Return XML from aspx

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

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

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.


Here is the source I used:
 public static void ResponseXML(HttpResponse response, int statuscode, string desc)
            XmlDocument doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

            XmlElement root = doc.CreateElement("XML");
            root.SetAttribute("Version", "1.0");

            XmlElement xmlcode = doc.CreateElement("Code");
            xmlcode.InnerText = statuscode.ToString();

            XmlElement xmldesc = doc.CreateElement("Desc");
            xmldesc.InnerText = desc;
            response.StatusCode = statuscode;

            response.ContentType = "text/xml; charset=utf-8";     

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