I have a form on my site. The user enters their e-mail and selects a location from a dropdown. I then need to post that data to an external site by hitting a url with the user's location and e-mail in the query string.
I'm doing this like so:
string url = "http://www.site.com/page.aspx?location=" + location.Text + "&email=" + email.Text;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
My client says that I am not hitting their server, but when going through the debugger, I'm getting a response from their server. I also tried tracking what was happening by using Firebug, and I noticed that there was no POST made to that external site.
What am I doing wrong here?
string line;
HttpWebRequest request = WebRequest.Create("http://www.yahoo.com") as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
StreamReader streamr = new StreamReader(response.GetResponseStream());
line = streamr.ReadToEnd();
can u get to ma post i have written all over der
Make sure you're doing a POST and not a GET method. This is some similar code that I've used in the past.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "POST";
request.Timeout = 30000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
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