c# - why is it making the request twice -


this code written send request service , receive simple json response service's server log shows being requested twice delay of 1 second. cant figure out why code make request twice please guide me if there configuration missing.

string strurl = @"http://www.myapp.com/tracker.json"; uri uri1 = new uri(strurl); httpwebrequest webrequest1 = (httpwebrequest)httpwebrequest.create(uri1); webrequest1.servicepoint.connectionlimit = 1; webrequest1.timeout = 50000; webrequest1.readwritetimeout = 50000 webrequest1.preauthenticate = false; webrequest1.proxy = null; webrequest1.cookiecontainer = cookiejar; webrequest1.method = "post"; webrequest1.keepalive = false;  webresponse response1 = webrequest1.getresponse();  streamreader streamreader1 = new streamreader(response1.getresponsestream()); string responsedata1 = streamreader1.readtoend(); 

these might similar problems

why http client making 2 requests when specify credentials?

https://social.msdn.microsoft.com/forums/vstudio/en-us/dad87752-42dd-4346-a1c5-da30f6156406/why-httpwebrequest-send-data-twice-in-https

this problem solved using restsharp (simple rest , http api client .net).

var client = new restclient("http://www.myapp.com/tracker.json"); // client.authenticator = new httpbasicauthenticator(username, password);  var request = new restrequest("", method.post);  // execute request restresponse response = client.execute(request); var content = response.content; // raw content string 

read article comparison of webclient, httpclient , httpwebrequest


Comments