请问,我现在有一个Default.aspx文件,当有人访问这个Default.asp页面的时候,我会返回一个XML格式的字符串给那个访问者,但是我怎么每次返回的都是页面的HTML,请问这是什么原因?

解决方案 »

  1.   

    Response.ContentType = "text/xml";
      

  2.   

    要不然在前台页面的head里面加
    <meta  http-equiv="content-type" content="text/xml"/>
    这个应该也是可以的
      

  3.   

    你就在.aspx页面的head标签中间加
    <meta  http-equiv="content-type" content="text/xml"/> 
    试试
    这个是html知识了
      

  4.   

    加了没用。
    我在  Default页面的Page_Load函数中加了
    StringBuilder xml = new StringBuilder();
            xml.Append("<?xml version=\"1.0\" encoding=\"gbk\"?>");
                .Append("<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchemainstance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" >");
                .Append("<soapenv:Body>");
                .Append("<ns3:MoSOAPRespBody xmlns:ns3=\"http://123.com/esms/\">");
                .Append("<ns3:message>");
                .Append("<id>"+id+"</id>");
                .Append("<result>"+"1"+"</result>");
                .Append("</ns3:message>");
                .Append("/ns3:MoSOAPRespBody");
                .Append("</soapenv:Body>");
                .Append("</soapenv:Envelope>");             Response.ContentType = "text/xml";
                this.Response.Write(returnValue);
    我要返回这个XML, 页面是一个<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!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 runat="server">
        <meta  http-equiv="content-type" content="text/xml"/> 
        <title></title>
    </head>
    <body></body>
    </html>请问我该怎么返回?