开发者

ASP.net membership saving data in 2 databases

In our application we are using asp.net membership database for user and role management. We installed the database tables in my existing SQL Express database and everything worked fine..

Later during development we were in need to store one additional information about the users ie:FullName

For this we created a profile in the web.config like this :

<profile enabled="true">
      <properties>
        <add name="FullName" type="string"/>
      </properties>
</profile>

It also worked, we were able to add and retrieve the full name of the user easily.. But to our surprise we found that the profile table in our database is empty.. upon further investigation we found that the profile information i开发者_如何学运维s not being saved in our regular sqlexpress database BUT IS SAVED in a new aspnetdb.mdf in the app-code folder..

Now whenever we create a new user its being created in both databases but the profile information ( ie: Full Name) is saved only in the aspnetdb.mdf

Can someone answer why its happening... ??

Here is the snippet of our web config where we are explicitly specifying that our own database needs to be used and not the default sqlmembershipprovider

<membership defaultProvider="CustomizedMembershipProvider">
  <providers>
    <clear/>
    <add name="CustomizedMembershipProvider"
     connectionStringName="MyConnectionString"
     applicationName="App209"
     commandTimeout="60"
     requiresQuestionAndAnswer="false"
     requiresUniqueEmail="true"
     enablePasswordRetrieval="true"
     enablePasswordReset="true"
     passwordFormat="Encrypted"
     maxInvalidPasswordAttempts="5"
     minRequiredPasswordLength="4"
     minRequiredNonalphanumericCharacters="0"
     passwordAttemptWindow="10"
     passwordStrengthRegularExpression=""
     type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</membership>
<roleManager enabled="true"
         defaultProvider="CustomizedRoleProvider">
  <providers>
    <add name="CustomizedRoleProvider"
     connectionStringName="MyConnectionString"
     applicationName="App209"
     type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</roleManager>

Any help? Thanks in advance


You have to configure the profile provider to use your connection string the same as the other two providers.

<profile defaultProvider="CustomizedProfileProvider" >
  <providers>
    <clear/>
    <add name="CustomizedProfileProvider" connectionStringName="MyConnectionString" applicationName="App209" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</profile>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜