Getting “SQLExpress database file auto-creation error” for site that uses AspNetSqlMembershipProvider, but connection string is to SQL Server 2005

后端 未结 3 1583
逝去的感伤
逝去的感伤 2021-01-18 05:03

I have an ASP.NET v2.0 website (not web application) where the root directory is public, but the \"Admin\" subdirectory requires authentication. Everything abo

3条回答
  •  佛祖请我去吃肉
    2021-01-18 05:49

    When you specify the AttachDBFilename option in the connection string you are in fact asking for your-very-own-just-in-time-provisioned SQL Server instance, aka the 'user instance'. This instance is created by asking the 'master' instance (the .\SQLEXPRESS instance) to provision a child instance, which implies copying the master/model/msdb into your profile, starting a new SQL Server process under your account configured to use the freshly copied master/model/msdb, then asking this 'child' instance to attach the specified 'file' as a new database. The details are explained in SQL Server 2005 Express Edition User Instances.

    The process of creating a child instance is extremly fragile and when it breaks the DB call results eventually in a time out error when opening the connection. In your case it seems that the process breaks in some cases (when you reach the protected part of the site). Why it breaks, is very hard to guess without proper information. Look at the Common Issues in the linked article and see if any applies to you. Also check the system event log for any message why the child instances cannot start or it cannot open the MDF file. Note that a common mistake is to ask for the same physical file with AttachDBFilename under different credentials: each credential will start its own 'child' instance and only the first one will succeed in attaching the desired database.

提交回复
热议问题