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
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
Post a Comment