0

I am calling a web api service that takes a textpage from umbraco(cms) and displays it's associated xml in a literal control. I am getting odd html output when comparing source versus a httpwebrequest.

I use this code in a page load to call the service

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://111.111.111.111:8080/api/PageContentApi?id=1122");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream stream = response.GetResponseStream();
                using (StreamReader reader = new StreamReader(stream))
                {
                    string html = reader.ReadToEnd();
                    aboutText.Text = html;
                }
            }

The string information I receive is:

[{"Id":1122,"Name":"sample","Alias":"bodyText","Value":"<p>This is a sample test</p>\r\n<p> </p>\r\n<p>two returns</p>\r\n<p> </p>\r\n<p>one return</p>\r\n<p>     spaces   spaces  <strong>bold  </strong><em> italic   </em><span style=\"text-decoration: underline;\">underline</span></p>\r\n<p> </p>\r\n<p><img width=\"201\" height=\"75\" src=\"http://111.111.111.111/media/1001/logo.gif\" alt=\"logo\"/></p>","Version":"b8cbd32e-b946-4b1f-ae72-2564b7757479","Created":"1/1/0001 12:00:00 AM","ParentId":-1}]

When I manually view the source in firefox after doing a get I see something completely different:

<ArrayOfPageContent xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/name.Models"><PageContent><Alias>bodyText</Alias><Created>1/1/0001 12:00:00 AM</Created><Id>1122</Id><Name>sample</Name><ParentId>-1</ParentId><Value>&lt;p&gt;This is a sample test&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;two returns&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;one return&lt;/p&gt;
&lt;p&gt;     spaces   spaces  &lt;strong&gt;bold  &lt;/strong&gt;&lt;em&gt; italic   &lt;/em&gt;&lt;span style="text-decoration: underline;"&gt;underline&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;img width="201" height="75" src="http://111.111.111.111/media/1001/logo.gif" alt="logo"/&gt;&lt;/p&gt;</Value><Version>b8cbd32e-b946-4b1f-ae72-2564b7757479</Version></PageContent></ArrayOfPageContent>

why am I seeing different types of responses and what is the best way to render this content grabbed from umbraco to a asp web page.

1 Answer 1

3

The information that you receive from your program is in the JSON format whereas with Firefox you are receiving it in the XML format.

If you read the documentation on umbraco, which I have not used, there is most likely a parameter you can add to the GET URL to ask for either JSON or XML.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.