I have a page where a user submits an order, and after they submit it, I want to hit a url (http://externalsite.com?id=12345&sessionid=abc123
) without actually redirecting them to the external page.
Is there a way to do this?
Sure, use an HttpWebRequest
from your server-side code. Here's an example:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
"http://externalsite.com?id=12345&sessionid=abc123");
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string result = reader.ReadToEnd();
// Process the response text if you need to...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With