help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

KB10008: System.InvalidOperationException: Timeout expired

when using AuthenticationModule for protecting documents


There are problems with viewing documents in Management System or Live System when the extension is mapped to ASP.NET 2.0 in IIS.
When trying to open the file, following exception is thrown.

Additonal Info:
ExceptionManager.MachineName: XXXXX
ExceptionManager.TimeStamp: 17.08.2006 11:45:53
Version=1.0.934.32109, Culture=neutral, PublicKeyToken=null
ExceptionManager.WindowsIdentity: NT AUTHORITY\NETWORK SERVICE

Exception Information
Axinom.Framework.FrameworkException: Connection cannot be opened.
=User;PWD=Password --->
System.InvalidOperationException: Timeout expired. The timeout
period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at Axinom.Framework.Data.ConnectionManager.Connection()
--- End of inner exception stack trace ---
at Axinom.Framework.Data.ConnectionManager.Connection()
at Axinom.Framework.Data.DbQuery.CreateCommand()
at Axinom.Framework.Data.DbQuery.ExecuteReader()
at Axinom.Framework.BL.PersistentObject.Load(IDbQuery query)
Axinom.AECMS.document.AxDocument.LoadByFileNameLS(String filename)
at AxCMS.AxCMSweb.AuthenticationModule.DoCheck()
AxCMS.AxCMSweb.AuthenticationModule.context_AuthorizeRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.ExecuteStep(IExecutionStepstep, Boolean& completedSynchronously)


The problem is caused by how the mapping is handled by ASP.NET 2.0 and IIS.
For all extensions without handler, root web.config specifies System.Web.DefaultHttpHandler as handler. This handler sends the request back to IIS. Then, IIS forwards the request back to ASP.NET, which ends again in DefaultHttpHandler, so it becomes an endless loop, which results in reaching the DB connection limit.


1. In the web.config, map the extension to System.Web.StaticFileHandler. So the request is processed by StaticFileHandler, never comes back to DefaultHttpHandler and no loop occurs. E.g.

<add verb="*" path="*.pdf" type="System.Web.StaticFileHandler, System.Web" />

2. Map the wildcard extension in IIS application mapping. This will also bring the request back to IIS from DefaultHttpHandler, but IIS has special logic to break the wildcard mapping loop, so it will also work fine. To do this, go to site properties, Home Directory tab, click Configuration, and then Insert wildcard mapping to ASP.NET 2.0 aspnet_isapi.dll.

MORE INFORMATION - Select your IIS version and read the Authentication section.

APPLIES TO versions: All versions

IIS versions: 5.x, 6.0