I want my website to make a call to a URL, and that's it. I don't need it to wait for a response. My ASP.Net project was previously using webRequest.BeginGetResponse(null, requestState) but has recently stopped working. No errors are thrown, but I have confirmed that the URL is never called.
When I use webRequest.GetResponse() the URL does get called but this approach is not asynchronous, which I need it to be.
Here is my code, any ideas of what could be wrong?
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
webRequest.Method = "GET";
NetworkCredential nc = new NetworkCredential("theUsername", "thePassword");
webRequest.Credentials = nc;
webRequest.PreAuthenticate = true;
RequestState rs = new RequestState();
rs.Request = webRequest;
IAsyncResult r = (IAsyncResult)webRequest.BeginGetResponse(null, rs);
This is the code that works but is not asynchronous..
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
webRequest.Method = "GET";
NetworkCredential nc = new NetworkCredential("theUsername", "thePassword");
webRequest.Credentials = nc;
webRequest.PreAuthenticate = true;
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();