A typical ASP.NET 2.0 Configuration Settings
A typical ASP.NET 2.0 Configuration Settings
Posted by: Rickie http://rickie.cnblogs.com
ASP.NET web application configuration is stored in a web.config file. This file is used to describe the properties and behaviors of various aspects of ASP.NET application.
A typical ASP.NET 2.0 web configuration file is as follows.
<
configuration
xmlns
=
"http://schemas.microsoft.com/.NetConfiguration/v2.0">
<
connectionStrings
>
<
add
name
=
"ConnectionStr1" connectionString="Server=(local); Database=aspnetdb; User ID=sa; Password=developer" />
</
connectionStrings
>
<
system.web
>
<
profile
defaultProvider
=
"SqlProvider">
<
providers
>
<
clear
/>
<
add
name
=
"SqlProvider"
connectionStringName
=
"ConnectionStr1"applicationName="TestApp"
type
=
"System.Web.Profile.SqlProfileProvider"
description
=
"SqlProfileProvider for SampleApplication"
/>
</
providers
>
<
properties
>
<
add
name
=
"FirstName"/>
<
add
name
=
"LastName"/>
<
add
name
=
"LastVisited"/>
<
add
name
=
"Age"/>
<
add
name
=
"Member"/>
</
properties
>
</
profile
>
<
membership
defaultProvider
=
"SqlProvider">
<
providers
>
<
clear
/>
<
add
name
=
"SqlProvider"
type
=
"System.Web.Security.SqlMembershipProvider, System.Web, Version=
connectionStringName
=
"ConnectionStr1"
requiresQuestionAndAnswer
=
"false"
requiresUniqueEmail
=
"true"
passwordFormat
=
"Clear"
minRequiredNonalphanumericCharacters
=
"0"
minRequiredPasswordLength
=
"3" />
</
providers
>
</
membership
>
<
roleManager
enabled
=
"true" defaultProvider="SqlProvider" >
<
providers
>
<
clear
/>
<
add
name
=
"SqlProvider"
type
=
"System.Web.Security.SqlRoleProvider"
connectionStringName
=
"ConnectionStr1"
/>
</
providers
>
</
roleManager
>
<
authentication
mode
=
"Forms">
<
forms
name
=
".ASPXAUTH"loginUrl="Login.aspx"
protection
=
"All"
timeout
=
"30"
path
=
"/"
requireSSL
=
"false"
slidingExpiration
=
"true"
/>
</
authentication
>
<
sessionState
mode
=
"InProc"
stateConnectionString
=
"tcpip=127.0.0.1:42424"
stateNetworkTimeout
=
"10"
sqlConnectionString
=
"data source=127.0.0.1; user id=sa; password=P@55worD"
cookieless
=
"false"
timeout
=
"20"
/>
<
compilation
debug
=
"true"/>
<!--
trace enabled ="true" pageOutput="true" /
-->
</
system.web
>
</
configuration
>
1. connectionStrings Section
ASP.NET 2.0 introduces a new section called <connectionStrings> that stores all kinds of connection-string information.
How to retrieve a connection string:
ConfigurationSettings.ConnectionStrings[“
ConnectionStr
2. profile Section
Profile section configures parameters for managing user profile values by using the ASP.NET profile.
The above sample shows how to configure an ASP.NET application to use to SqlProvider store data.
3. membership Section
In the above sample, we specify the default membership provider using the defaultProvider attribute of the membership element. The SqlProvider provider connects to a database server specified by the ConnectionStr1 element in <connectionStrings> section.
4. roleManager Section
The <roleManager> section configures an application for role management. The default role provider is specified as SqlProvider in the above sample, which connect to the same database server as the membership element.
5. authentication
Authentication is a process that verifies the identity of the user and establishes the identity between the server and a request.
ASP.NET 2.0 supports the following authentication methods.
Windows authentication / Passport / Forms
6. sessionState
ASP.NET 2.0 has the capability to persit the session store data in InProc, StateServer, SqlServer and Custom.
References:
1. MSDN
2. Professional ASP.NET 2.0 – Wrox
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?