 |
In Search of a "RequestTimeout" property...
[reply]
|
04/26/04 08:48 AM EST posted by JER email web |
|
A Q & A article on MSDN mentions that a programmer can modify the timeout of an HTTP request by using reflection to get at the members & methods of the System.Web.RequestTimeoutManager & System.Web.RequestTimeoutManager.RequestTimeoutEntry namespaces. This assertion is a bit misleading, though. Taking a look at this namespace via ILDASM, one can see that there is no "Timeout" attribute that can be modified in this location. So unless you want to remove your current request from the RequestTimeOutManager's thread pool and manage it yourself, you should write something like the following:
System.Web.HttpContext.Current.GetType().InvokeMember("Timeout", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.Instance, null, System.Web.HttpContext.Current, new object[] {new TimeSpan(0, 0, 0, 0, 1)});
If you test the code posted above, you'll see that even though I've specified a timeout of 1 millisecond, the actual page timeout will be closer to 15 seconds. The RequestTimeOutManager uses a System.Threading.Timer object to manage requests and checks thread status every 15 seconds. While it's unlikely you'll ever need a page timeout so small, just keep that in mind. |
|
Note: Only registered ShinyDonkey.com users
can post images. Only administrators can delete images.