c# - HttpRequest taking too long to respond. Works fine in browser -


i creating web request read response. response string around 100 characters. when hit url in browser responds in second, when try read response using below code times out. sometime throws error "unable connect remote server."

httpwebrequest request = (httpwebrequest)httpwebrequest.create(serviceurl);                     request.method = "get";                     request.useragent = "mozilla/5.0 (windows; u; windows nt 6.0; en-us; rv:1.9.0.5) gecko/2008120122 firefox/3.0.5";                     request.proxy = null;                     string responsestring = string.empty;                      using (httpwebresponse response = (httpwebresponse)request.getresponse())                     {                         stream datastream = response.getresponsestream();                         streamreader reader = new streamreader(datastream);                         responsestring = reader.readtoend();                         reader.close();                         datastream.close();                     } 

i have added following web.config

<system.net>     <connectionmanagement>       <add address ="*" maxconnection ="65535"/>     </connectionmanagement> </system.net> 

can point out what's wrong doing? why endpoint works fine in browser not code?


Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -