ASP. NET-configuration file provider

Source: Internet
Author: User

 

ASP. NET configuration file and ASP. NET membership, ASP. NET role management, and other ASP. NET functions use the same provider-based structure. The ASP. NET configuration file function is a hierarchical system. The configuration file function (providing typed property values and managing user IDs) is separated from the basic data storage zone. The configuration file function depends on the configuration file provider (data provider) to perform the backend tasks required to store and retrieve the configuration file attribute values.

 

1. Default Configuration File provider

ASP. NET contains a configuration file provider that uses Microsoft SQL server to store data. The default ASP. NET Computer Configuration contains a default instance of sqlprofileprovider named aspnetsqlprofileprovider, which is connected to the SQL server on the local computer. By default, the ASP. NET configuration file function uses this instance of the provider. Alternatively, you can specify a different default provider in the web. config file of the application.

To use sqlprofileprovider, you must first create the SQL Server database used by sqlprofileprovider. You can create a database by running the aspnet_regsql.exe command in the following path:

SYSTEMROOT/Microsoft. NET/SDK/version

You can specify the-AP option when running the tool. The following command demonstrates the specific syntax used to create a database required to store the ASP. NET configuration file using sqlprofileprovider:

Aspnet_regsql.exe-AP

The preceding example does not specify a name for the created database. Therefore, the default name is used. The default database name is aspnetdb.

If you configure the configuration file provider by using an integrated security connection string, the process account of the ASP. NET application must have the permission to connect to the SQL Server database.

Note: If the SQL Server 2005 express edition database is used and the default configuration is used when the database is installed, and the database and the Web server are on the same computer, Asp. net will automatically create the configuration file database.

 

2. Custom configuration file providers

In some cases, you may want to create and use a custom configuration file provider. If you already have a database that stores user information (such as an employee database), if you want to use a database other than Microsoft SQL server, or use a different data storage area (such as an XML file ), this is often required.

The attributes stored in the user configuration file can be provided by different configuration file providers. Therefore, you can manage data from multiple data sources to store the information of a single user configuration file.

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.