Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
The request that is sent by the HttpWebRequest class may stop responding when you use the HttpWebRequest class in an ASP.NET application
| Article ID | : | 904262 |
| Last Review | : | May 21, 2007 |
| Revision | : | 1.4 |
SYMPTOMS
When you use the
HttpWebRequest class in a Microsoft ASP.NET application, the request that is sent by the
HttpWebRequest class may stop responding.
Back to the top
CAUSE
This behavior may occur when the
HttpWebRequest class and the
HttpWebResponse class are used to make a HTTP or HTTPS request from an ASP.NET page and the ASP.NET page times out before the request is finished. When the ASP.NET page times out, the request is aborted. The aborted request may leave the connection that was initiated by the
HttpWebRequest class in an unknown state and may cause the request to fail.
Note Managed code classes such as SOAP and remoting internally use the
HttpWebRequest class. Therefore, managed code classes may exhibit the same behavior.
Back to the top
WORKAROUND
To work around this behavior, you must make sure that the ASP.NET time-out value is large enough to handle sending the request with the
HttpWebRequest.GetResponse method and reading the response stream that is retrieved by using the
HttpWebResponse class.
Note The HTTP request is made up of the following parts:
| 1. | Sending the request is covered by using the HttpWebRequest.Timeout method. |
| 2. | Getting the response header is covered by using the HttpWebRequest.Timeout method. |
| 3. | Reading the body of the response is not covered by using the HttpWebResponse.Timeout method. In ASP.NET 1.1 and in later versions, reading the body of the response is covered by using the HttpWebRequest.ReadWriteTimeout method. The HttpWebRequest.ReadWriteTimeout method is used to handle cases where the response headers are retrieved in a timely manner but where the reading of the response body times out. |
You set the ASP.NET time-out value in the web.config file or in the machine.config file that uses the
executionTimeout property in the
<httpRuntime> section.
Note If the
debug property in the .config file is set to
true, the
executionTimeout property is ignored.
You must set the ASP.NET
executionTimeout setting to a value that is larger than or equal to the value that is determined by the following formula:
(HttpWebRequest.Timeout * 2) + HttpWebRequest.ReadWriteTimeout
Back to the top
STATUS
This behavior is by design.
Back to the top
REFERENCES
For more information, see the following Microsoft Developer Network (MSDN) Web sites:
Back to the top
APPLIES TO
| • | Microsoft ASP.NET 1.1 |
| • | Microsoft ASP.NET 1.0 |
Back to the top
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please