Posting xml data back extra html tags get inserted

308 Views Asked by At

I have a website that makes request to our page on http://www.xyz.com/test.aspx and in return we have to post back the response. Following code is what is sending the response back. Problem is it sends the XML data back but with it also it sends the code of test.aspx I don't know how to remove that.

Random random = new Random();
int randomNumber = random.Next(0, 10000000);
attrval = randomNumber + "tty";
strCXML = "<?xml version=" + "\"" + "1.0" + "\"" + " encoding=" + "\"" + " UTF-8" + "\"" + " ?>";      
strCXML =strCXML+"<!DOCTYPE cXML SYSTEM " + "\"" + "http://xml.cxml.org/schemas/cXML/1.2.023/cXML.dtd" + "\"" + ">";
strCXML = strCXML + " <cXML payloadID=" + "\"" + attrval + "\"" + " timestamp=" + "\"" + strTimeStamp + "\"" + ">";
strCXML = strCXML + "<Response>";
strCXML = strCXML + "   <Status code=" + "\"" + 200 + "\"" + " text=" + "\"" + "success" + "\"" + ">" + "</Status>";
strCXML = strCXML + "   <PunchOutSetupResponse> ";
strCXML = strCXML + "     <StartPage>";
strCXML = strCXML + "       <URL>" + strMySiteURL + "</URL>";
strCXML = strCXML + "     </StartPage>";
strCXML = strCXML + "   </PunchOutSetupResponse>";
strCXML = strCXML + " </Response>";
strCXML = strCXML + "</cXML>";
Response.Write(strCXML);

This is working fine except that when it posts the data back it also is including the html of test.aspx page

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title></head>
<body>

</body>
</html>
  Please contact support with the Error Reference Number: ANERR-10000000000000000057040121 for more details</Status>
        </Response>
</cXML>

Any ideas how I post it back so it only posts back the XML data above.

1

There are 1 best solutions below

0
On

You need to call Response.End after you write the xml to stream, otherwise the site will continue to render the page.