-
Nov 24th, 2013, 11:05 AM
#1
Thread Starter
Fanatic Member
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?
-
Nov 24th, 2013, 08:54 PM
#2
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
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Nov 24th, 2013, 09:02 PM
#3
Thread Starter
Fanatic Member
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>
-
Nov 28th, 2013, 11:09 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|