help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

KB10008: System.InvalidOperationException: Timeout expired

when using AuthenticationModule for protecting documents

SYMPTOMS

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
ExceptionManager.FullName:
Microsoft.ApplicationBlocks.ExceptionManagement,
Version=1.0.934.32109, Culture=neutral, PublicKeyToken=null
ExceptionManager.AppDomainName:
/LM/W3SVC/300702360/Root-3-128002806759758695
ExceptionManager.ThreadIdentity:
ExceptionManager.WindowsIdentity: NT AUTHORITY\NETWORK SERVICE

Exception Information
Axinom.Framework.FrameworkException: Connection cannot be opened.
ConnectionString=SERVER=(local);DATABASE=DB;UID
=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.
at
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at
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)
at
Axinom.AECMS.document.AxDocument.LoadByFileNameLS(String filename)
at AxCMS.AxCMSweb.AuthenticationModule.DoCheck()
at
AxCMS.AxCMSweb.AuthenticationModule.context_AuthorizeRequest(Object sender, EventArgs e)
at
System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStepstep, Boolean& completedSynchronously)



CAUSE

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.

SOLUTION

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.

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

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

http://en.help.axinom.de/en_help_cms_inst_iis.AxCMS?ActiveID=1353 - Select your IIS version and read the Authentication section.

APPLIES TO

AxCMS.net versions: All versions

IIS versions: 5.x, 6.0