ASP.Net MVC3 Azure - Do I Need Membership Provider

2019-06-23 19:24发布

问题:

I am creating my first ASP.Net MVC3 Application using Azure as DB Storage. There are a number of great tutorials but I'm currently using this one: Walkthrough: Hosting an ASP.NET Web Application on Windows Azure

I've got my connection string hooked to Azure and its working fine. I run the application in Debug mode and "Register" my first user via the Membership Provider. According to the walkthrough, "Creating an account causes ASP.NET to create the membership database." Success! I now see the tables (Users, Roles,...) have been created in my Azure database. Great!

Why I'm Confused: Many years ago, when I did an ASP.Net 2.0 using the Membership Provider, I used the aspnet_regsql.exe to run all the scripts needed for the Membership Provider. I know they have an updated set of scripts for Azure. These scripts create all the tables but also create a large number of Stored Procedures (ex. aspnet_Membership_CreateUser)

My question: Do I need to run these updated Azure scripts to get the SPs? I don't see any Stored Procedures created in my database yet all the Membership Provider functionality seems to work just fine without them. What were all those Stored Procedures used for? Do I need them in my MVC3 Azure application?

Thanks!

回答1:

Since you’re following that tutorial, you’re already using the ASP.NET Universal Providers. One step in the tutorial adds the universal providers as a NuGet package. You can refer to http://nuget.codeplex.com/ for more information about NuGet. A Nuget package is essentially some pre-written code, which simplifies your development. For example, the universal providers automatically create the membership database tables based on your connection string. You can of course, continue to manually create the database tables, and then use the built-in ASP.NET membership provider.



回答2:

You should actually use the ASP.NET Universal Providers For SqlExpress 1.1. This is the officially supported method of enabling the SQL membership, role and session providers across both SQL Azure and standalone SQL Server. The Universal Providers should automatically create the necessary SQL objects for you, so you shouldn't have to run any scripts manually.

Here are a couple of links for reference:

Scott Hanselman - Introducing System.Web.Providers

SQL Azure Team Blog - Using SQL Azure for Session State