WebControls.Login.MembershipProvider

S

Steven Nagy

Hidey ho,

C#, ASP.NET, VS2005, SQL Server 2005 Developer

I've used aspnet_regsql to install the membership/role tables into my
application database.
I have confirmed that all the tables are there.
I've also configured the web.config to specify the new database as the
role provider and the membership provider. I have used the "ASP.NET
Configuration" tool to manage users and roles. These are definately
saved to the database mentioned above. All this works great.

I have added a WebControls.Login control to the form and, by default,
the username/password is not accepted (even though the custom
membership provider is specified as default in the web.config). I
changed the property of "MembershipProvider" for the control and
specified my custom membership provider. Still no love.

To trouble shoot, I handled the "LoginError" event of the Login control
and discovered that it doesn't think the username exists which makes me
think its still not talking to the correct database. I DO have SQL
Express installed on the same machine, along with SQL Server 2000 as
well.

Here's my web.config entries for my providers:

<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="DBCS" />
</providers>
</roleManager>

<membership defaultProvider="CustomizedMembershipProvider">
<providers>
<add name="CustomizedMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="DBCS"
minRequiredNonalphanumericCharacters="0"
minRequiredPasswordLength="7" />
</providers>
</membership>



Any help is appreciated!

Thanks,
Steven
 
S

Steven Nagy

I fixed this problem. For those interested:

The user that got created was being inserted with an "Application" name
of "\myapp" however by default, the web config entry for the membership
provider assumes an application name of "\" so it was querying the
database asking for a user of "steven" in the "\" app instead of the
"\myapp". Even though when I went to the ASP.NET Web configuration, I
clicked the radio that specifies one membership profile per application
(instead of one for ALL applications), it still set up the tables as
though it was going to be reused across multiple applications.

So the actual fix was an entry in the web config for the member
provider, specifying the application name, here's an example:

<membership defaultProvider="CustomizedMembershipProvider">
<providers>
<add name="CustomizedMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
applicationName="/myApp"
connectionStringName="MyDBC"
minRequiredNonalphanumericCharacters="0"
minRequiredPasswordLength="7" />
</providers>
</membership>


Hope this helps future readers. Don't reply to this if it did, just
send me money.

SN
 
S

Sean Chambers

I've actually banged my head against the wall in the past over this
same problem. Finally I figured out the problem and was cursing the
membership controls.
 
S

Steven Nagy

Its good that it makes sense once you work out the problem.
And I guess its a mistake you will only make once.
But still, its not as intuitive as it could be.
 
S

Sean Chambers

I agree completely, the first time I tried to figure it out it took me
quite awhile.

Oh well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top