Abstract:Describes how to create a new ASP. NET membership relationship, role management, and personalized services, so as to replace Microsoft SQL Server Express with conventional SQL Server.
NoteThis articleFirst publishedScott's network diary. Please goHereJoin the discussion.
Content on this page
|
Quick review: What is the new ASP. NET 2.0 application service? |
|
Default SQL Express provider |
|
Summary |
Quick review: What is the new ASP. NET 2.0 application service?
Microsoft ASP. NET 2.0 contains many built-in "construction block" application services. The reason we call them "Constructor blocks" is that they are useful core frameworks that can be used for the current Web application in exceptional circumstances-therefore, they can greatly improve production efficiency and save time for developers.
These construction blocks include:
• |
The member relationship API (used to manage user names, passwords, and security creden。) and role API (supports ing users to logical groups ). |
• |
The configuration file API is used to store any attributes (such as zip code, gender, and topic preferences) of verified users and anonymous users who access the Web site ). |
• |
Personalized APIs are used to store custom control preferences (usually used together with the WebPart feature in ASP. NET 2.0 ). |
• |
The status monitoring API is used to track and collect information about the running status and any errors that occur within the Web application. |
• |
The site navigation API is used to define the internal hierarchy of the application, and construct a context-specific navigation UI (menu, tree view, and detailed Path Tracking) based on the location of the currently passed-in user in the site ). |
The ASP. NET Application Service API is pluggable and the implementation process is unknown, which means that the API does not hard encode the detailed information of the data storage location. On the contrary, Apis call "providers", while "providers" implement specific "provider conventions" (defined as an abstract class, class with a set of defined methods/attributes that the API expects to implement.
ASP. NET 2.0 comes with many built-in providers, including:
• |
Microsoft SQL Server Express provider for the local SQL Express database. |
• |
Microsoft SQL Server 2000/2005 for mature SQL Server. |
• |
Active Directory provider for AD or ADAM. |
• |
Bind the XML provider of the XML file on the file system (for site navigation ). |
The advantage of this model is that, if you do not like the included existing providers or want to integrate these APIs for existing data storage, you only need to implement a provider and insert it into the model. For example, you may already have an existing database that stores the user name/password, or an existing LDAP system to be integrated. You only need to implement the membership relationship provider Convention as a class, and in the Application web. in the config file. all calls to the membership API in. NET are delegated to the code.
Back to Top
Default SQL Express provider
Frankly speaking, most ASP. NET 2.0 application services are configured to use built-in SQL Express providers. When you use an application service for the first time, the provider automatically creates and provides a new database, and provides a very simple getting started method, there is no need for too many installation steps (as long as SQL Express is available ). Note that the SQL Express database can also be upgraded to run in the context of a mature SQL Server instance. Therefore, applications developed using SQL Express can be easily upgraded to a high-capacity, cluster failover Security 8 p SQL box, and the applications developed will be more successful.
How to Use the provisionerSQL ExpressChange to useSQL Server?
To use a mature SQL Server 2000 or SQL Server 2005 database instance (instead of SQL Express), follow these steps:
Procedure1: Create or retrieve a blankSQLDatabase instance
The procedure creates or retrieves a connection string pointing to an empty standard SQL database instance.
Procedure2: Provide yourSQLDatabases andASP. NETArchitecture
Open a command line window in the system and run. the aspnet_regsql.exe utility installed together with NET 2.0 is located in C: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.xyz directory.
Note that this utility can be run in GUI-based mode or with the command line switch (Add a "-?" Mark to view all switch options ).
With this wizard, you can learn how to create architectures, tables, and stored procedures for the built-in SQL provider included in ASP. NET 2.0. Figure 1 to Figure 5 shows the step-by-step drill process.
Figure1. SQL ServerInstallation Wizard, Welcome Screen
Figure2. SQL ServerInstallation Wizard to configure application services
Figure3. SQL ServerIn the Installation Wizard, select the server and database
Figure4. SQL ServerInstallation Wizard, confirm the settings
Figure5. SQL ServerInstallation Wizard complete
After the drill wizard is complete, all database architectures and stored procedures supporting application services will be installed and configured. (Note: We also provide the original content in the above framework directory. SQL file. If the DBA wants to know exactly what happened internally, You can manually drill and/or run these files to install the DB .)
Procedure3: MakeWeb. configThe file points to the newSQLDatabase
Currently, ASP. NET 2.0 supports a new section named in the web. config file, which (apparently) is used to store connection strings. From a management perspective, one of the advantages is that the new ASP. net mmc snap-in now provides a GUI-based way to configure and manage these connection strings (6 ).
Figure6. ASP. NETManage connection strings on the page
ASP. NET 2.0 now supports encryption of any stored in the web. the section in the config file, so you can safely store private data (for example, connection strings) without writing any encryption code.
ASP. NET 2.0 comes with a built-in connection string named LocalSqlServer. By default, it is configured to use the SQL Express database, as well as services such as membership, role, personalization, configuration file and status monitoring.
The easiest way for applications to automatically take advantage of the newly created SQL database is to replace the connection string value set by LocalSqlServer in the Local web. config of the application.
For example, if I create a database in the appservicesdb database instance of the Local Computer and use Windows integrated security for connection, I will change the Local web. config file to specify this operation.
<configuration> <connectionStrings> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Data Source=localhost; Initial Catalog=appservicesdb; Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings></configuration>
Click Save. All built-in application services now use the newly created and newly defined SQL Server database.
NoteOne disadvantage of this method is that the LocalSqlServer connection string name is reused-if I deploy a database on another machine, it will feel awkward. If you want to name it your own connection string name, you only need to add a brand new connection string, and then specify the existing provider to use the new connection string name to replace the default LocalSqlServer connection string.
Back to Top
Summary
Although the application services provided by ASP. NET 2.0 use SQL Server 2005 Express by default, changing it to SQL Server 2000 or 2005 is quite simple. Once changed, you will be able to enjoy the benefits of these database engine features.