Originally, due to browser security restrictions, cross-domain access to network connections is not allowed. We cannot directly use Ajax on the browser side to access resources across domains, but there is no such cross-domain security restriction on the server side. Therefore, we only need to ask the server side to help us with "cross-origin access" and then directly obtain the results of "cross-origin access" on the server side. I hope it will be helpful to share my solutions. Pai_^
Certcheck. aspx: CopyCode The Code is as follows: Using msxml2;
Namespace Ca 2
{
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: Copy codeThe Code is as follows: <? XML version = "1.0"?>
<Root>
</Root>
PS: You can directly write parameters in XH. Send,
Certcheck. aspx:Copy code The Code is as follows: using system. net;
Using system. IO;
Namespace Ca 2
{
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 Copy codeThe Code is as follows: 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 ();
}