Solved

Entries into dbo.Users, not dbo.aspnet_Users

Posted on 2012-12-23
8
1,080 Views
Last Modified: 2013-01-15
I have migrated some ASP.Net 2.0 code to ASP.Net 4.5 and am having a problem with adding users and roles. The new information is going into a table dbo.Users in the aspnetdb database rather than dbo.aspnet_Users as it used to. Why is this and how do I get it to work as before? Is there a new API I should be using?
0
Comment
Question by:steve_webber
  • 5
  • 3
8 Comments
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 38717549
Just replace this,

 <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>

Open in new window


with this,


<membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>

Open in new window

0
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 38717550
0
 

Author Comment

by:steve_webber
ID: 38717738
This did not work. I created my aspnetdb database using aspnet_regsql.exe and all of the tables within the database so created have their names prefixed with "aspnet_". The views created reference the tables with these names. However, when I try to execute

      Roles.CreateRole("Administration")
      Membership.CreateUser("admin@appforms.com", "foobar123", "admin@appforms.com")
      Roles.AddUserToRole("admin@appforms.com", "Administration")

it creates new tables which do not have "aspnet_" at the beginning of the names. It places the new role in the dbo.Roles table and can't add the user because it is looking for dbo.aspnet_Roles (via the views which still reference dbo.aspnet_Roles).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:steve_webber
ID: 38717741
It appears that the new user was added to the ado.aspnet_Users table, but the role was added to ado.Roles table and the error occurs trying to add the user to the role.
0
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 38718047
Can you specify the error.
0
 

Author Comment

by:steve_webber
ID: 38718329
The error returned was "The user 'admin@appforms.com' was not found." I assume this is because it was looking in dbo.Users instead of dbo.aspnet_Users.
0
 

Accepted Solution

by:
steve_webber earned 0 total points
ID: 38718384
The problem was that I should not have tried to use aspnet_regsql.exe at all. This is apparently all automatic with ASP.Net 4.5. I am using the web.config that was generated by default and it works fine. I'm not sure why it was referencing the aspnet_Roles table, and I'll try to figure this out.
0
 

Author Closing Comment

by:steve_webber
ID: 38777589
I determined by myself that i was using an obsolete mechanism to create the membership database. It is created automatically, with different table names, with ASP.Net 4.5.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Client Validating 2 date fields, required & comparison 1 49
Testing of the web services 1 47
ASP.net Markup for Sub Menu 2 39
Web page design problem 3 12
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question