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

后端 未结 3 1584
逝去的感伤
逝去的感伤 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:39

    According to your comment, it looks like you have haven't explicitly configured a role provider for you site.

    If all that's in your web.config is:

    
    

    Then you are relying on the default providers declared further up the configuration hieracrchy (machine.config, global web.config, etc)

    In machine.config you've probably got something like:

    
      
        
        
      
    
    

    As you can see, the first provider is configured to use a connectionString called LocalSqlServer - which is also usually declared in the machine.config:

    
    

    And this is designed to use a local file based database that will be created if it doesn't already exist.

    So to get roles working on your site, you should ammend your root web.config to something like:

    
      
        
        
      
    
    

    Using the element will remove all previously defined providers for that type.

提交回复
热议问题