发布xml数据后会插入额外的html标签

时间:2012-10-05 23:16:45

标签: c# asp.net xml cxml

我有一个网站向http://www.xyz.com/test.aspx页面发出请求,作为回报,我们必须回复回复。以下代码是发回响应的内容。问题是它发回XML数据但是它也发送了test.aspx的代码 我不知道如何删除它。

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);

这个工作正常,但是当它发布数据时它还包括test.aspx页面的html

!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>

任何想法我如何发回它所以它只回发上面的XML数据。

1 个答案:

答案 0 :(得分:2)

在将xml写入流后,需要调用Response.End,否则该站点将继续呈现页面。