System.Web.HttpException: Request timed out error?
I have a thread class which makes a web request. After 20-30 urls request, its开发者_运维百科 throwing exception: System.Web.HttpException: Request timed out. My code is below where it is throwing exception:
httpReq.AllowAutoRedirect = false;
httpReq.KeepAlive = false;
httpReq.Headers.Add("Location", "");
httpReq.Timeout = this.HttpRequestTimeout;
httpRes = (HttpWebResponse)httpReq.GetResponse();
In last line : httpRes = (HttpWebResponse)httpReq.GetResponse(); it is throwing exception. "The remote server returned an error: (403) Forbidden."
I am using session for setting some values with the request header.
I got the answer. I was not using httpRes.close() method after using response object. That's why after 80-90 request it was returning : "The remote server returned an error: (403) Forbidden ".
精彩评论