Question

On creating a new MVC project, Visual Studio take cares of SqlMembershipProvider if it is a non-empty project. VisualS Studio creates a Database and all necessary Tables.

But, I have an existing MVC 3 project and i would like to add/integrate SqlMembershipProvider.

How can I add SqlMembershipProvider and create all needed Tables in my existing Database?

Était-ce utile?

La solution

You need to run

Aspnet_regsql.exe   ( this creates the necessary tables into your existing database)

Take a look here: What's difference between windows and forms authentication in asp.net mvc 4?

YES, ignore the sections of code that refer to comparison for windows and forms authentication. However, it should serve as useful information on SQLMembershipProvider which uses the Membership and MembershipUser classes to provide these membership services to a ASP.NET application.

Aspnet_regsql.exe

http://msdn.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider(v=vs.90).aspx

Autres conseils

You can use the Microsoft ASP.NET Universal Providers nuget package

ASP.NET Universal Providers add provider support in ASP.NET 4 for all editions of SQL Server 2005 and later and to SQL Azure. If you use these providers to develop your application, the application will be ready for cloud environments like Azure. Other than supporting additional storage options, the providers work like the existing SQL-based providers, so that you can easily switch an application to use cloud storage via SQL Azure.

And for this great Hanselman's post

The configuration for these providers is the same as the existing SqlMembershipProvider class, but the type parameter is set to the type of the new providers, as shown in the following table:

SQL Provider Types -> Equivalent Type for Universal Providers System.Web.Security.SqlMembershipProvider -> System.Web.Providers.DefaultMembershipProvider System.Web.Profile.SqlProfileProvider -> System.Web.Providers.DefaultProfileProvider System.Web.Security.SqlRoleProvider -> System.Web.Providers.DefaultRoleProvider (Built in provider) System.Web.Providers.DefaultSessionStateProvider

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top