天天看點

C#下xmlhttp 中文亂碼完美解決方案

添加引用:

是MS XMLV2.6(不是V6.0,原因知道的同志給我答案)

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

using  System;

C#下xmlhttp 中文亂碼完美解決方案

using  System.Data;

C#下xmlhttp 中文亂碼完美解決方案

using  System.Configuration;

C#下xmlhttp 中文亂碼完美解決方案

using  System.Web;

C#下xmlhttp 中文亂碼完美解決方案

using  System.Web.Security;

C#下xmlhttp 中文亂碼完美解決方案

using  System.Web.UI;

C#下xmlhttp 中文亂碼完美解決方案

using  System.Web.UI.WebControls;

C#下xmlhttp 中文亂碼完美解決方案

using  System.Web.UI.WebControls.WebParts;

C#下xmlhttp 中文亂碼完美解決方案

using  System.Web.UI.HtmlControls;

C#下xmlhttp 中文亂碼完美解決方案

using  MSXML2;

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

public   partial   class  _Default : System.Web.UI.Page 

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

... {

C#下xmlhttp 中文亂碼完美解決方案

    protected void Page_Load(object sender, EventArgs e)

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

    ...{

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

    }

C#下xmlhttp 中文亂碼完美解決方案

    protected void Button1_Click(object sender, EventArgs e)

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

    ...{

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

        string mSiteName = TextSarcher.Text.Trim();

C#下xmlhttp 中文亂碼完美解決方案

        MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTP();

C#下xmlhttp 中文亂碼完美解決方案

        //string Url = "http://X.X.X.X/getservice.php?sitename=" + mSiteName + "";

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

        xmlhttp.open("GET", Url, false, null, null);

C#下xmlhttp 中文亂碼完美解決方案

        xmlhttp.send("");

C#下xmlhttp 中文亂碼完美解決方案

        MSXML2.XMLDocument dom = new XMLDocument();

C#下xmlhttp 中文亂碼完美解決方案

        Byte[] b = (Byte[])xmlhttp.responseBody;

C#下xmlhttp 中文亂碼完美解決方案

               //string Flag = System.Text.ASCIIEncoding.UTF8.GetString(b, 0, b.Length);

C#下xmlhttp 中文亂碼完美解決方案

        string andy = System.Text.Encoding.GetEncoding("GB2312").GetString(b).Trim();

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案

        //Response.Write(Url);

C#下xmlhttp 中文亂碼完美解決方案

        //Response.Write(Flag);

C#下xmlhttp 中文亂碼完美解決方案

        Response.Write(andy);

C#下xmlhttp 中文亂碼完美解決方案

        //Response.End();

C#下xmlhttp 中文亂碼完美解決方案

    }

C#下xmlhttp 中文亂碼完美解決方案

}

C#下xmlhttp 中文亂碼完美解決方案
C#下xmlhttp 中文亂碼完美解決方案