To obtain data from an ashx page, use the following methods:
1.
Copy codeThe Code is as follows:
WebClient wc = new WebClient ();
Byte [] pageData = wc. DownloadData ("http://xxxx.com ");
Hd_num.Value = Encoding. Default. GetString (pageData );
Front-end code: <asp: HiddenField ID = "hd_num" runat = "server"/>
Then obtain the value of hd_num through js.
2.
Copy codeThe Code is as follows:
HttpWebRequest request = HttpWebRequest. Create ("http: // xxx/aaa. ashx") as HttpWebRequest;
HttpWebResponse response = request. GetResponse () as HttpWebResponse;
Stream resStream = response. GetResponseStream ();
StreamReader sr = new StreamReader (resStream, System. Text. Encoding. Default); // The Encoding can be changed to another
ContentHtml. Text = sr. ReadToEnd ();
3.
You can also use ajax cross-origin requests. This part is still being studied.
The data that has been processed is transmitted from my ashx page.