Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've set HttpWebRequest time out like following way.

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ImageUrl);
 request.Method = "HEAD";
 request.UseDefaultCredentials = true;
 request.Accept = "*/*";
 request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

bool exist = false;
try{
    //request.ReadWriteTimeout = 1000;
    request.Timeout = 1000;
    request.GetResponse();
    exist = true;
}
catch{
   //
}
<pre>

Whenever a request is made on ImageUrl which is not exist, it takes too much time to get request response. It's taking too much time for ImageUrls which starts with Https://

What I have tried:

I've tried above code but not getting request timeout.

Is the code right or wrong? when a request made for ImageUrl on which image is not exist, it takes morethan 2seconds to get response of the request.
Posted
Updated 20-May-16 0:00am

You have to set Request Timeout in your web.config file
for example

XML
<system.web>
    <httpRuntime executionTimeout="160" />
</system.web>


for more information please follow below links
increase request timeout ? [^]

IIS Request Timeout on long ASP.NET operation - Stack Overflow[^]

How to increase the time out for request/response ? | The ASP.NET Forums[^]


Regards,
AARIF SHAIKH
 
Share this answer
 
Comments
[no name] 20-May-16 6:40am    
Not helpful, still it's taking much time.
you can set the Timeout property of your request object.
C#
request.Timeout = 3000

note: the value is in milliseconds.
 
Share this answer
 
Comments
[no name] 20-May-16 6:39am    
I've set request time out property to request object. refer above code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900