Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Request from c# program, requiring no response

Tags:

c#

I've done some socket work where I had to send a request because I wanted a response back, but I need to write something in C# that's just going to call an old web page which takes about 10 seconds to respond, and not wait for the response (the failures will flag up with DB calls).

Is there a simple way to do this?

like image 603
Tim Almond Avatar asked Jun 10 '11 16:06

Tim Almond


2 Answers

Try this thread: Async HttpWebRequest with no wait from within a web application

(This kind of approach is sometimes known as "fire and forget")

like image 104
Rick Liddle Avatar answered Oct 12 '22 23:10

Rick Liddle


You can use the Async methods on the System.Net.WebClient class:

var webClient = new System.Net.WebClient();
webClient.DownloadStringAsync("your_url")
like image 23
David Avatar answered Oct 12 '22 23:10

David