views:

351

answers:

1

I have an ASP.NET site under development on my computer. It has it's own sqlserver database. For some reason the membership provider system seems to create two application records for the project. This causes problems for me since the membership system is creating two records, one for each application record, for each user in the system. Why is this happening and how do I turn it off?

The major reason this is a problem is that I use the username to recover the membershipID of each new user and so members can be related to other tables we create for data storage.

Any suggestions or references would be appreciated.

Thanks

Doug

+2  A: 

This usually happens when you don't specify a name for the "applicationName" attribute of the Membership provider. This will cause the Membership provider to use the vroot path of your web server.

In the example below you can see the default value of the applicationName attribute, if you don't have it specified:

<membership>
<providers>
    <clear/>
    <add name="AspNetSqlMembershipProvider"
     type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
     connectionStringName="LocalSqlServer"
     enablePasswordRetrieval="false"
     enablePasswordReset="true"
     requiresQuestionAndAnswer="true"
     requiresUniqueEmail="false"
     passwordFormat="Hashed"
     maxInvalidPasswordAttempts="5"
     minRequiredPasswordLength="7"
     minRequiredNonalphanumericCharacters="1"
     passwordAttemptWindow="10"
     passwordStrengthRegularExpression=""
     applicationName="/"
     />
</providers>

So, if you for instance move your application from one folder to another, a new application is being created in the membership database.

The way to solve this is to give a name to your "applicationName" attribute. If you already have membership data you want to use you can name the attribute as one of your existing application names. It is the "ApplicationName" column of the "aspnet_Application" table.

ScottGu had a good post on this here:

Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Mircea Grelus