Hi VS2010 with MVC4. Somehow I have both asp_Membership and webpages_Membership going at the same time. That is through the website I can register a user. However, when using ASP.NET configuration I get a message that there are no users are set up. When
looking in the folder location App_Data I find a sql database named, aspnetdb.mdf. So somehow I seem to have activated both authentication databases.
How do I resolve this to use the webpages_Membership?
I have both asp_Membership and webpages_Membership going at the same time.
Looks like you got tables for both Membership Provider and SimpleMembership Provider.
KiwiJonathan
That is through the website I can register a user.
If it is MVC4 application then it will use SimpleMembership Provider and data will be in the table starting with webpages_[*]
KiwiJonathan
However, when using ASP.NET configuration I get a message that there are no users are set up.
ASP.NET configuration is not supported over SimpleMembership Provider and it can not be used to configure the User and Roles, you need to use WebSecurity API to store the role in the SimpleMembership tables.
KiwiJonathan
When looking in the folder location App_Data I find a sql database named, aspnetdb.mdf. So somehow I seem to have activated both authentication databases.
Make sure you have clean version of application pointing to simpleMembership db, it will avoid other confusion as well.
Ooops sorry I did not express the question clearly. Instead of using the ASP.NET configuration button, how do I run the WebSecurity API or am I required to assign roles using code (as shown in your reply above). If I assign roles using code do you have a
link to a tutorial or example I can use?
KiwiJonathan
Member
1 Points
6 Posts
aspnet_Membership plus webpages_Membership
Feb 25, 2013 12:16 AM|LINK
Hi VS2010 with MVC4. Somehow I have both asp_Membership and webpages_Membership going at the same time. That is through the website I can register a user. However, when using ASP.NET configuration I get a message that there are no users are set up. When looking in the folder location App_Data I find a sql database named, aspnetdb.mdf. So somehow I seem to have activated both authentication databases.
How do I resolve this to use the webpages_Membership?
Many thanks,
CPrakash82
All-Star
18270 Points
2839 Posts
Re: aspnet_Membership plus webpages_Membership
Feb 25, 2013 01:16 AM|LINK
Looks like you got tables for both Membership Provider and SimpleMembership Provider.
If it is MVC4 application then it will use SimpleMembership Provider and data will be in the table starting with webpages_[*]
ASP.NET configuration is not supported over SimpleMembership Provider and it can not be used to configure the User and Roles, you need to use WebSecurity API to store the role in the SimpleMembership tables.
Make sure you have clean version of application pointing to simpleMembership db, it will avoid other confusion as well.
KiwiJonathan
Member
1 Points
6 Posts
Re: aspnet_Membership plus webpages_Membership
Feb 25, 2013 01:18 AM|LINK
Hi, how do I use WebSecurity API?
CPrakash82
All-Star
18270 Points
2839 Posts
Re: aspnet_Membership plus webpages_Membership
Feb 25, 2013 01:27 AM|LINK
For Role creation
Roles.CreateRole("Administrator"); //or some other value
For adding user to a particular role, use code similar to below
if (!Roles.GetRolesForUser("[someuser]").Contains("Administrator")) // check if user is part of the role
Roles.AddUsersToRoles(new[] {"[someuser]"}, new[] {"Administrator"}); // if not then add the user to the role
KiwiJonathan
Member
1 Points
6 Posts
Re: aspnet_Membership plus webpages_Membership
Feb 25, 2013 07:59 PM|LINK
Ooops sorry I did not express the question clearly. Instead of using the ASP.NET configuration button, how do I run the WebSecurity API or am I required to assign roles using code (as shown in your reply above). If I assign roles using code do you have a link to a tutorial or example I can use?
Many thanks,