Reputation: 1
I'm trying to use ASP.NET MVC to my new project and have been expected that the user authentication should be rather simple there. My goal is to have a separate user database table in my main database.
I thought that the SqlTableProfileProvider should be the solution. So I added the corresponding table into my database and changed the web.config file. But it seems no matter what I change there, my web application still using the default authentication (via ASPNETDB.mdf file).
What could be the problem?
(my web.config file beginning is:)
Upvotes: 0
Views: 811
Reputation: 9917
Do what I do and forget about rolling your own membership provider etc or using sqltableprofileprovider - instead extend the tables that the default membership adds through relations to your own table(s) which contains the extra data you want to store.
So, add another table to your database called 'Details', for example, then set the primary key to be related 1 to 1 to the primary key of the aspnet_Users table. Use this new table as you would any other. When you want the primary key of a user, use the membership api to grab it.
not tested!
Guid userID = (Guid)Membership.GetUser(username).ProviderUserKey;
Then add the data you require to your details table and your set.
Just seems more flexible to me - although I'm probably doing it all wrong! :)
Upvotes: 1
Reputation: 532455
See this reference on how to create the standard application services tables and associated database entities in your SQL server database. Once done it should be a simple matter of changing the default Application Services connection string in the web.config file to use the built-in providers for membership, roles, and profiles.
Upvotes: 1