[ASP. NET 2.0] custom role, membership and profile database, in Web. config

Source: Internet
Author: User
Tags connectionstrings

1. Membership provider

<Configuration>
<Connectionstrings>
<Add name = "sqlservices" connectionstring = "Data Source = mysqlserver; Integrated Security = sspi; initial catalog = aspnetdb;"/>
</Connectionstrings>
<System. Web>
<Membership defaultprovider = "sqlprovider" userisonlinetimewindow = "20">
<Providers>
<Remove name = "aspnetsqlprovider"/>
<Add name = "sqlprovider"
Type = "system. Web. Security. sqlmembershipprovider"
Connectionstringname = "sqlservices"
Enablepasswordretrieval = "false"
Enablepasswordreset = "true"
Requiresquestionandanswer = "true"
Passwordformat = "hashed"
Applicationname = "/"/>
</Providers>
</Membership>
</System. Web>
</Configuration>

2. Role provider

<Configuration>
<Connectionstrings>
<Add name = "sqlservices" connectionstring = "Data Source = mysqlserver; Integrated Security = sspi; initial catalog = aspnetdb;"/>
</Connectionstrings>

<System. Web>
<Rolemanager defaultprovider = "sqlprovider"
Enabled = "true"
Cacherolesincookie = "true"
Cookiename = ". asproles"
Cookietimeout = "30"
Cookiepath = "/"
Cookierequiressl = "false"
Cookieslidingexpiration = "true"
Cookieprotection = "encrypted">

<Providers>
<Clear/>
<Add
Name = "sqlprovider"
Type = "system. Web. Security. sqlroleprovider"
Connectionstringname = "sqlservices"
Applicationname = "myapplication"/>
</Providers>

</Rolemanager>
</System. Web>
</Configuration>

3. Profile

<Configuration>
<Connectionstrings>
<Add name = "sqlservices" connectionstring =
"Data Source = mysqlserver; Integrated Security = sspi; initial catalog = aspnetdb;"/>
</Connectionstrings>
<System. Web>
<Profile enabled = "true" defaultprovider = "sqlprovider">
<Providers>
<Clear/>
<Add name = "sqlprovider"
Type = "system. Web. profile. sqlprofileprovider"
Connectionstringname = "sqlservices"
Applicationname = "myapplication"/>
</Providers>
</Profile>
</System. Web>
</Configuration>

--------------------------------------------------------------------------------

References:

Http://msdn2.microsoft.com/zh-cn/library/system.web.security.membership.providers (vs.80). aspx

Http://msdn2.microsoft.com/zh-cn/library/system.web.security.roles.providers (vs.80). aspx

Http://msdn2.microsoft.com/zh-cn/library/system.web.profile.profilemanager.providers (vs.80). aspx

Http://www.cnblogs.com/thcjp/archive/2006/11/19/565092.aspx

Http://www.odetocode.com/Articles/427.aspx

Http://www.odetocode.com/Articles/428.aspx

 

Related Article

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.