0

I want to add roles to my website in asp.net mvc 3 so that only an specific role can look at certain controllers.

I read the music store tutorial, and went to the asp .net web administration tool and read that I can customize my provider in the provider tab.

I have in a table called Client from my database and it has columns "Username" "Password" etc. I want to check the login info in these tables.

I went to the provider tab and I can only see AspNetSqlProvider I cannot see a way to add my database there or anything...(the database is already in my project)

How can I configure this. I've search online but haven't found how. Could anyone point me in the direction to do this?

3
  • implement a custom membership provider. Commented Mar 13, 2011 at 4:38
  • BTW, "ASP.NET" is one word - no space. Commented Mar 13, 2011 at 4:48
  • it doesnt seem like you have needs that the default membership provider can't handle. research using that before building your own. even basic things like storing passwords in a database are non-trivial to implement correctly/securely. Commented Mar 13, 2011 at 5:09

3 Answers 3

1

Microsoft developed a much simpler membership provider called SimpleMembership, that allows you to very easily use an existing database and specify where your usernames/passwords are stored. It was originally introduced for use with the ASP.NET WebPages framework, in WebMatrix, but there already exists a NuGet package that allows you to use it with ASP.NET MVC:

webSecurityService.InitializeDatabaseConnection(
    connectionStringName: "Default", 
    userTableName: "Users", 
    userIdColumn: "ID", 
    userNameColumn: "Username", 
    autoCreateTables: true);

SimpleMembership.Mvc3 NuGet Package

Sign up to request clarification or add additional context in comments.

Comments

0

You will need to implement a custom membership provider that knows how to check your custom database schema. Here is a video that might get you started. There are heaps of resources online too now that you know the correct terminology to search for ;)

Comments

0

Have a look at Universal Membership Provider Works with SQL Express, Compact, and Azure. Just give it a connection string to your membership DB.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.