Results 1 to 4 of 4

Thread: Adding a Provider to Membership

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    523

    Adding a Provider to Membership

    I am trying to use the ASP Membership database, and I am having trouble getting the provider connected. I added the following to my Web.Config.

    Code:
     <membership defaultProvider="SqlMembershipProvider">
            <providers>
              <clear />
              <add
                name="SqlMembershipProvider"
                type="System.Web.Security.SqlMembershipProvider"
                connectionStringName="NewsletterSQLConnectionString"
           />
            </providers>
          </membership>
    The connectionstring exists, and I am able to use it on the page to load and access a GridView control. In the Website Administration Tool, under Provider, and selecting 'Select a single provider for all site management data', I don't see any providers, indicating that this new provider is not loaded. If I remove the Clear, I do see the AspNetSqlProvider, however when I test it I get the error that it can not connect to the database. Any suggestions on how to resolve this problem?

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Adding a Provider to Membership

    Hi. You can't recall if SqlMembershipProvider is the default provider, if so then you need to have a unique name for the Provider, not SqlMembershipProvider. Rename it to something else like "MySqlProvider" and add that provider to the providers node.
    Note that you will also need a role manager provider
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    523

    Re: Adding a Provider to Membership

    I finally got it to work. This is what I ended up with.

    Code:
     <connectionStrings>
        <clear/>
        <add name="LocalSqlServer" connectionString="Data Source=coasph-4tvnkq1\sqlexpress;Initial Catalog=NewsletterSQL;Integrated Security=True" providerName="System.Data.SqlClient"/>
     </connectionStrings>

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Adding a Provider to Membership

    Hello,

    The reason that this would have been failing is that the AspNetSqlProvider entry exists in the machine.config file, and this would have been using the wrong ConnectionString to your database. Putting the clear in basically says that for this site, ignore everything in the machine.config file, and use what I declare in this web.config file.

    Can you remember to go back and mark your thread as resolved?

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width