ASP. NET routine full code version (7) -- self-configured member role management library in 2.0

Source: Internet
Author: User
Complete ASP. NET routinesCodeVersion (7) -- self-configured member role management library in 2.0
Author: zyf0808 published on:ArticleAttribute: Original Copy Link

In ASP. NET 2.0 provides a good Member-role management mechanism for us to conveniently implement user registration and role allocation, and encapsulate and implement basic member access and role control, however, by default, the aspnetdb database used to provide role management for Members is stored in the Express version of SQL Server 2005, the following describes how to use configuration tools to achieve integrated development of VS 2005 and SQL Server 2000 by establishing a personal site solution.
First, after VS 2005 is installed, if file --> New --> Web site --> personal Web site starter kit is then run directly, an error will certainly occur, an error has occurred while establishing a connection to the server is prompted. when connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL server does not allow remote connections. (provider: SQL network interfaces, error: 26-error locating server/instance spec Ified ). However, vs provides us with a very convenient tool. You can use aspnet_regsql.exe on the command line to specify the default database server. It will automatically generate the aspnetdb library for managing members, that is, roles, under the configured database server. This tool can be used in the command line and provides the UI to facilitate application configuration. Program Used database. Aspnet_regsql


When using this starter kits, you can store the personal library in SQL Server 2000 through the script provided by it, instead of using attachdbfilename. You can configure it through web. config as follows:
<Connectionstrings>
<Add name = "personal" connectionstring = "Data Source = yourserver; Integrated Security = true; initial catalog = personal"/>
<Add name = "sqlservices" connectionstring = "Data Source = yourserver; Integrated Security = sspi; initial catalog = aspnetdb;"/>
<Remove name = "localsqlserver"/>
</Connectionstrings>
By default, the connection is machine. you can remove the localsqlserver defined in config without using the default membership & roles provider. remove the default provider in config. The following configuration is available:
<Rolemanager>
<Providers>
<Add name = "aspnetsqlroleprovider" connectionstringname = "localsqlserver" applicationname = "/" type = "system. web. security. sqlroleprovider, system. web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a "/>
</Providers>
</Rolemanager>
Because we have removed the default localsqlserver connection string. If we do not remove the aspnetsqlroleprovider, the connection name 'localsqlserver' was not found in the applications configuration or the connection string is empty.
You can use the following custom settings:
<System. Web>
<Rolemanager enabled = "true" defaultprovider = "aspnetroleprovider">
<Providers>
<Remove name = "aspnetsqlroleprovider"/>
<Add name = "aspnetroleprovider" connectionstringname = "sqlservices"
Type = "system. Web. Security. sqlroleprovider, system. Web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a"
Applicationname = "/"/>
</Providers>
</Rolemanager>
<Membership defaultprovider = "aspnetmembershipprovider" userisonlinetimewindow = "20">
<Providers>
<Remove name = "aspnetsqlmembershipprovider"/>
<Add name = "aspnetmembershipprovider"
Type = "system. Web. Security. sqlmembershipprovider"
Connectionstringname = "sqlservices"
Enablepasswordretrieval = "false"
Enablepasswordreset = "true"
Requiresquestionandanswer = "true"
Passwordformat = "hashed"
Applicationname = "/"/>
</Providers>
</Membership>
</System. Web>
After such configuration, you can use VS 2005 & SQL Server 2000 for member access and role management development. Haha, I hope it will be helpful to my friends who have just been involved in 2.0 development.

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.