title: Getting "SQLExpress database file auto-creation error" for site that uses AspNetSqlMembershipProvider, but connection string is to SQL Server 2005
body: <p>I have an <code>ASP.NET v2.0</code> website (not web application) where the root directory is public, but the "Admin" subdirectory requires authentication.  Everything about the setup is very generic - I used a connection string defined in the root web.config, and the standard <code>AspNetSqlMembershipProvider</code> provider, and I'm using the ASP.NET Login control.<br>
  The web.config in the Admin directory specifies that the user must have the "Admin" role. </p>
  
  <p>I'm using <code>SQL Server 2008</code>, and my connection string is good; every root level page is data driven and they all work fine.<br>
  Provider configuration seems goo.</p>
  
  <p>when I log in, the Login control's "<code>OnLoggedIn</code>" event fires.<br>
  The last line in that event code redirects me down to my <code>Admin/Default.aspx</code> page.  My breakpoint in "OnLoggedIn" shows me that all's well until the redirect down into my Admin directory...and then...</p>
  
  <p>...and then I wait...and wait...</p>
  
  <p>And then I get an error telling me it's experienced a "<code>SQLExpress database file auto-creation error</code>."</p>
  
  <p>Why in the world is it suddenly trying to create a SQL Server Express file?  Why is it suddenly ignoring my connection string?</p>
  
  <p>One odd clue: Just before the last line of the "OnLoggedIn" event I put in this:</p>
  
  <pre><code>bool blnTest = User.IsInRole("Admin");
  </code></pre>
  
  <p>I wanted to see if <code>blnTest = true</code>.<br>
  What happens is the process hits this line...and waits...and eventually tells me it can't access the SQL Server Express database.  It seems that any reference (either in my code, or behind the scenes) to determine the User's Role, calls the wrong database.</p>
  
  <p>EDIT:  Argh, <em>sometimes</em> it waits when I test blnTest.  Other times it immediately reports the value as "false."</p>