"Azure Services Platform Step by step-14th" uses the Azure version of ASP.net creator Providers

Source: Internet
Author: User
Keywords Name password user
Tags .net applications asp asp.net based class cloud code
asp.net creator providers believes that we are already very familiar with the development of asp.net applications.

The login section in the Visual Studio Control Toolbox, for example, is based on membership provider, session provider, and profile provider, which greatly simplifies our process of dealing with user-related functionality during development.

 

(see http://msdn.microsoft.com/en-us/library/aa479030.aspx for more provider information)

asp.net provider architecture diagram

Class structure diagram of ASP.net provider

 

What's Azure provider?

Applications on Azure are also asp.net applications, so it also supports the ASP.net provider model. The difference is that the provider we use is based on relational databases (such as SQL Server), and the "cloud" provider naturally need to use a "cloud" of data solutions Windows Azure Storage.

The cloud platform is based on distributed computing. This means that your application may be distributed across different machines. So a variety of user data, including sessions, cannot be placed on host hosts and must be managed through Windows Azure storage.

Microsoft believes that the Windows Azure storage provider has the following advantages over traditional SQL provider:

On the basis of maintaining the exact same usage as the SQL provider (without making any code modifications),

Parallel processing is more powerful.

Paging queries are more convenient.

The computational power is more than the Ox x.

Run more stable.

The principle of Azure provider

In the Windows Azure SDK (procures 2009 CTP), Microsoft has provided an azure version of ASP.net Provider that can be used directly. Including membership, role, profile, the session of the state 4 kinds of providers.

Open the azure version of ASP.net provider project, very at a glance. The following 4 files correspond to 4 kinds of provider one by one.

Take Tablestoragemembershipprovider, it actually inherits the MembershipProvider class (refer to the provider class structure diagram above), Override the methods associated with data manipulation in the MembershipProvider class, replacing them with Windows Azure Table storage version.

public class Tablestoragemembershipprovider:membershipprovider

Configure to use Azure Provider:

Just now, switching from a traditional SQL Provder to using Azure Provider without making any changes to the code, you just need to change the configuration file.

The following is an example of a memshipprovider configuration. (other provider are similar, please refer to the code in the attachment)

<membership defaultprovider= "Tablestoragemembershipprovider"

Userisonlinetimewindow = "n"

<providers>

<clear/>

<add name= "Tablestoragemembershipprovider"

type= "M Icrosoft. Samples.ServiceHosting.AspProviders.TableStorageMembershipProvider "

description=" membership provider Using table storage "

applicationname=" providertest "

tableservicebaseuri=" Your table service en Dpoint '

allowinsecureremoteendpoints= ' false '

accountname= ' youraccountname '

sharedkey= ' Y            Oursharedkey "

Membershiptablename=" membership "

Enablepasswordretrieval=" false "

Enablepasswordreset= "true"

Requiresquestionandanswer= "false"

Minrequiredpasswordlength= "1"

minrequirednonalphanumericcharacters= "0"

requireSuniqueemail= "true"

passwordformat= "hashed"

/>

</providers>

< /membership>

Code Download:

Example code using Azure provider: Http://file.ddvip.com/2009_03/1237975802_ddvip_6085.rar

Azure provider Source code: Http://file.ddvip.com/2009_03/1237975847_ddvip_5154.rar

Storageclient: Source code Download:

Http://file.ddvip.com/2009_03/1237975906_ddvip_8708.rar

The data dimension of Azure provider:

Provider

Storage

Membership

Table Storage

Profile

Table storage for storing management data

Blob storage for storing the actual profile data

Session state

Table storage for storing management data

Blob storage for storing the actual session state

Role provider

Table Storage

Membership Table

Column

Type

Comment

Partition Key

String

Concatenation of creator name and user name

Row Key

String

4¥î, empty string

User Name

String

User ID

Guid

Password

String

Max 128 characters because of encode limitations

Password format

String

. NET Regular Expression

Password Salt

String

Email

String

Password question

String

Password Answer

String

IsApproved

Bool

Isanonymous

Bool

Islockedout

Bool

CreateDate

DateTime

In UTC

Lastlogindate

DateTime

In UTC

Lastpasswordchangedate

DateTime

In UTC

Lastlockoutdate

DateTime

In UTC

Lastactivitydate

DateTime

In UTC

Failedpasswordattemptcount

Int

Failedpasswordattemptwindowstart

DateTime

In UTC

Failedpasswordanswerattemptcount

Int

Failedpasswordanswerattemptwindowstart

DateTime

In UTC

Comment

String

profilelastupdated

DateTime

In UTC

Profileblobname

String

Blob where profile data is stored

Profileiscreatedbyprofileprovider

Bool

Profilesize

Int

Size of profile data; Saved to save roundtrips

Role Table

Column

Type

Comment

Partition Key

String

Concatenation of creator name and user name

Row Key

String

Role name

Creator Name

String

User Name

String

Role name

String

Session State Table

Column

Type

Comment

Partition Key

String

Creator name + Session ID

Row Key

String

Not used, empty string

Id

String

Creator Name

String

Blob Name

String

References Session BLOB

Timeout

DateTime

Expires

DateTime

In UTC

Created

DateTime

In UTC

Lock Date

DateTime

In UTC

Locked

Bool

Lock

Int

Initialized

bool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.