Saturday, March 28, 2009

Resolution: The Underlying Connection Was Closed

You usually got this exception when trying to use System.Net.HttpWebRequest class in .NET 1.1 for creating internal URL calls from your ASP.NET code. The exception is also reproducible when trying to invoke webservices using the proxy class.

By default, there is two concurrent connections in every ASP.NET application. As ASP.NET is a service it may require more than two concurrent connections to handle the requests. When you try to request URL from your ASP.NET code, ASP.NET may not be able to handle it. The solution is to increase the number of the concurrent connections which ASP.NET can handle. You can do so by modifying the "connectionManagement" element in the configuration file. For more information about the problem and its resolution, check this post.