|
CertCheck.ASPx:
复制代码 代码如下:
using MSXML2;
namespace CA2
{
public partial class CertCheck : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request["resultid"] != null)
{
string s = Request["resultid"];
string[] result = s.Split('@');
Label1.Text = result[1];
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load("VBR.xml");
System.Xml.XmlElement RegNode = xmlDoc.CreateElement("Id");
RegNode.InnerText = result[0];
xmlDoc.DocumentElement.AppendChild(RegNode);
RegNode = xmlDoc.CreateElement("Serial");
RegNode.InnerText = result[1];
xmlDoc.DocumentElement.AppendChild(RegNode);
MSXML2.XMLHTTP xh = new MSXML2.XMLHTTPClass();
xh.open("POST", "http://222.19.211.119/CAProcess.ASPx", false, null, null);
xh.setRequestHeader("Content-Type", "text/xml");
xh.setRequestHeader("Content-Type", "gb2312");
xh.send(xmlDoc.InnerXml);
if (xh.readyState == 4)
{
if (xh.status == 200)
{
Label1.Text += "###" + xh.responseText;
}
}
}
}
}
}
VBR.xml:
复制代码 代码如下:
<?xml version="1.0"?>
<root>
</root>
PS: 在xh.send()中可以直接写参数,
CertCheck.ASPx:
复制代码 代码如下:
using System.NET;
using System.IO;
namespace CA2
{
public partial class CertCheck : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request["resultid"] != null)
{
string s = Request["resultid"];
string[] result = s.Split('@');
Label1.Text = result[1];
string param = "Id="+result[0]+"&Serial="+result[1];
byte[] bs = Encoding.ASCII.GetBytes(param);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://222.19.211.119/CAProcess.ASPx");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = bs.Length;
Stream reqStream = req.GetRequestStream();
reqStream.Write(bs, 0, bs.Length);
reqStream.Close();
HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("GB2312"));
string content = reader.ReadToEnd();
reader.Close();
myResponse.Close();
Label1.Text += "###" + content.ToString();
}
}
}
}
CAProcess.ASPx
复制代码 代码如下:
protected void Page_Load(object sender, EventArgs e)
{
int Id = int.Parse(Request.Form["Id"]);
string Serial = Request.Form["Serial"];
//
Response.Write(Id.ToString()+" "+Serial);
Response.End();
}
AspNet技术:ASP.NET XmlHttp跨域访问实现代码,转载需保留来源!
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。