I'm setting up membership in my ASP.NET MVC4 app, so I open the solution and then from there, I open up the ASP.NET Configuration website option under the "Project" menu. This opens up the ASP.NET Configuration tool to create/modify/delete users. What I'm finding is when I create a user, it creates the user in a local database when I specifically set in the web.config to point to a DIFFERENT database hosted with my web hosting company. I put <remove name="LocalSqlServer" />
to remove the connection defined in machine.config.
Here's the connection string in the web.config for my app:
<remove name="LocalSqlServer" />
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=cp.speedwell.arvixe.com; Initial Catalog=*********; User ID=********; Password=********;" />
Here's my database structure that's with my web hosting company. As you can see, I have all of the aspnet_ tables already created:
When I click on "Providers" in the ASP.NET Configuration tab, here's my list of providers:
DefaultMembershipProvider is pointed to "DefaultConnection" which is the connection string to the database hosted with my web hosting company. When I click "Test", it immediately comes back saying:
Finally, when I click on Security, here's the message I get (keep in mind I removed LocalSqlServer from my connection strings):
Any ideas what I'm doing wrong?
UPDATE
Here are my Membership, Profile, RoleManager, and SessionState sections of my web.config:
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add connectionStringName="DefaultConnection" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="false"
requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</providers>
</membership>
<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
<providers>
<add connectionStringName="DefaultConnection" applicationName="/"
name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
Turns out, my Users/Roles/Etc were actually being inserted into the correct database all along- they were being inserted into the Users table, not the aspnet_Users table, as I would expect. This is because my app was configured to use the asp.net universal providers.
Since I'm using MYWSAT, and it requires the old aspnet tables, I removed the universal providers and it now has moved past that problem. The reason I was getting that message saying that it couldn't establish a connection to the database was exactly because of this.