Question

hi i m trying to enable roles in asp Web Site Administration Tool but when go to the security tab it give me this error

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database.

and i'm using my own connectionStrings to link it to sql server management studio 2012 not to sql CE in the visual studio this is the code

 <connectionStrings>

<add name="MusicStoreEntities"
     connectionString="Data Source=localhost;
     Initial Catalog=Project4DB;
     Integrated Security=true;
     MultipleActiveResultSets=true"

     providerName="System.Data.SqlClient" /> 
</connectionStrings>

so how can enable roles in this case.

Was it helpful?

Solution

hi i mange to make ASP Web Site Administration Tool security tab work after many searches and hours. to connect to a regular server management studio 2012 not that one comes with visual studio

first make the following changes in the web.config file :

NOTE: we msut first of all have the database created in the server management studio 2012

1) add your connection string

 <connectionStrings>

    <add name="MusicStoreEntities" --> change the name to your own connection name 
     connectionString="Data Source=localhost;
     Initial Catalog=Project4DB; --> change it to your one database name
     Integrated Security=true;
     MultipleActiveResultSets=true"
     providerName="System.Data.SqlClient" />

 </connectionStrings>

2) in the <system.web> section in the web.config add

<roleManager enabled="false" 
  cacheRolesInCookie="false" 
  cookieName=".ASPXROLES" 
  cookieTimeout="30" 
  cookiePath="/" 
  cookieRequireSSL="false" 
  cookieSlidingExpiration="true" 
  cookieProtection="All" 
  defaultProvider="AspNetSqlRoleProvider" 
  createPersistentCookie="false" 
  maxCachedResults="25">

  <providers>
  <clear />
  <add connectionStringName="MusicStoreEntities" --> change the name to your own connection name
       applicationName="/" 
       name="AspNetSqlRoleProvider" 
       type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

 <add name="AspNetWindowsTokenRoleProvider" 
      applicationName="/" 
      type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

  </providers>
</roleManager>

and

<membership>
  <providers>
    <remove name="AspNetSqlMembershipProvider"/>
    <add name="AspNetSqlMembershipProvider" 
        type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        connectionStringName="MusicStoreEntities" --> change the name to your own connection name
        enablePasswordRetrieval="false" 
        enablePasswordReset="true" 
        requiresQuestionAndAnswer="true" 
        applicationName="/" 
        requiresUniqueEmail="false" 
        passwordFormat="Hashed" 
        maxInvalidPasswordAttempts="5" 
        minRequiredPasswordLength="7" 
        minRequiredNonalphanumericCharacters="1" 
        passwordAttemptWindow="10" 
        passwordStrengthRegularExpression=""/>
</providers>
</membership>

and

<customErrors mode="Off" />

3) open aspnet_regsql from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe

and follow the setup wizard

hit next

hit next

hit next

choose what database want to connect to then next

and the security tab from ASP Web Site Administration Tool will work to enable the roles.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top