0

I'm writting Simple Membership and Role Provider. I'm trying run the code from post http://www.brianlegg.com/post/2011/05/09/Implementing-your-own-RoleProvider-and-MembershipProvider-in-MVC-3.aspx but on run IIS show me error:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Line 39:       <providers>
Line 40:         <clear />
Line 41:         <add name="LocalBankMembershipProvider" type="LocalBank.Helpers.LocalBankMembershipProvider, LocalBank" connectionStringName="LocalBankEntities" />
Line 42:       </providers>
Line 43:     </membership>

Message Parser Error: Target call threw an exception.
Line: 41

Where I made a mistake at the start of the project? Convert project using Nuget package from mvc3 to mvc4

how can I fix this error?

xpasd
  • 81
  • 1
  • 6

1 Answers1

0

Did you followed advise given in comments section on the same link?

Few things to try:

  1. It might be the connection string that is wrong and due to which you are seeing this error. Change the connection string (e.g. data source). If you still see an issue, debug the project and see where exactly it is stuck and what more information you can get. I was able to reproduce this issue and with changes in connection string it was solved.

  2. When you debug you will see it will throw exception when it checks role exists. As per the blog, you need to add default role "Manager":

The only thing to note is there are no roles created. If you look inside the AccountController Register HttpPost action you'll notice that any user who registers through this site is given a default role of "Member". This can be changed, but whatever role this is must first already be created in the Role table. You can do this by writing a script (most likely preferred method) or you can write some hacky code and call it real quick since it will only need to be ran 1 time when first creating roles. Here's some example code you can use to create the "Member" role, modify it to suit your needs.

LocalBankRepository repo = new LocalBankRepository(); 
repo.AddRole("Member"); 
repo.Save(); 

Call those 3 lines from somewhere in your code (or a separate "initializer" project) and from then on the code should work as expected. Sorry for the confusion.

If you still face issue share with more details. Hope this helps.

SBirthare
  • 5,117
  • 4
  • 34
  • 59