web.config, administration.config, GAC, roles, and providers???

Discussion in 'Windows / IIS' started by guht, Jul 26, 2010.

  1. I am trying unsuccessfully to setup roles and providers for my website, and it seems the more I read, the more confused I become.

    I want to use windows form authentication, and I want to authenticate against my SQL database.

    I have used the aspnet_regsql tool, and it created the schema successfully inside of my database. I have verified this.

    I have tried to add settings to my web.config file to establish a custom provider pointing to my database, and I get an error about needing to add this custom provider as a trusted provider.

    In order to do that I need to edit the administration.config file, and store something in GAC, which I am assuming this would need to exist on discountasp's end and not locally on my developer machine, and that I would not have access to the administration.config and/or GAC.

    Do I need to use a custom provider or can I use the AspNetSqlRoleProvider with a custom connection string point to my discountasp SQL server?

    A SHOVE in the right direction with a definitive example would be nice! ;)

    Thanks!
     
  2. Bruce

    Bruce DiscountASP.NET Staff

  3. Thanks Bruce, ultimately that shoved me in the right direction! ;)

    From that article the only thing I would add is that it didnt really specify WHERE in the web.config file you need to put the connection string.

    Also I ended up having to add a membership node to the file, and a machinekey node.

    This is what that portion of my web.config file looks like now:

    Code:
        <appSettings/>
      <connectionStrings>
        <remove name="LocalSqlServer" />
        <add name="LocalSqlServer" connectionString="Data Source=sqlservername;Integrated Security=false;Initial Catalog=databasename;User ID=username;Password=password" providerName="System.Data.SqlClient" />
      </connectionStrings>
      
        <system.web>
    
          <machineKey validationKey="InsertYourOwnRandomlyGeneratedMachineKeyHere" validation="SHA1" decryption="AES" />
          
          <membership>
            <providers>
              <remove name="AspNetSqlMembershipProvider"/>
              <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web,    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="Encrypted" maxInvalidPasswordAttempts="3" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"/>
            </providers>
          </membership>

    I used this website to randomly generate my machine key.

    http://aspnetresources.com/tools/machineKey

    Hope this helps others!
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    thanks for the follow up post.
     

Share This Page