webconfig 配置细节

本文为原创作品,欢迎转载,请保留出处:http://www.cnblogs.com/Simcoder

 

一直都对配置文件不太理解,工作了终于鼓起勇气,去学习,即便不太熟悉,也要了解更多。。。

 

1.ASP.NET 配置文件为 XML 文件,ASP.NET 配置数据存储在 XML 文本文件中,每一个 XML 文本文件都命名为 Web.config(约定俗成)。

2.认识 Machine.config :

在运行中输入:%SystemRoot%         

webconfig 配置细节_第1张图片

 然后依次找到以下目录:%SystemRoot%\Microsoft.NET\Framework\版本号\CONFIG\ machine.config

我使用的VS2008 文件路径是:C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIGwebconfig 配置细节_第2张图片

3. machine.config的配置

代码
<? xml version="1.0" encoding="UTF-8" ?>
<!--
    Please refer to machine.config.comments for a description and
    the default values of each configuration section.

    For a full documentation of the schema please refer to
    http://go.microsoft.com/fwlink/?LinkId=42127

    To improve performance, machine.config should contain only those
    settings that differ from their defaults.
-->
< configuration >
  
< configSections >
    
< section  name ="appSettings"  type ="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  restartOnExternalChanges ="false"  requirePermission ="false"   />
    
< section  name ="connectionStrings"  type ="System.Configuration.ConnectionStringsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  requirePermission ="false"   />
    
< section  name ="mscorlib"  type ="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowLocation ="false"   />
    
< section  name ="runtime"  type ="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowLocation ="false"   />
    
< section  name ="assemblyBinding"  type ="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowLocation ="false"   />
    
< section  name ="satelliteassemblies"  type ="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowLocation ="false"   />
    
< section  name ="startup"  type ="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowLocation ="false"   />
    
< section  name ="system.codedom"  type ="System.CodeDom.Compiler.CodeDomConfigurationHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
< section  name ="system.data"  type ="System.Data.Common.DbProviderFactoriesConfigurationHandler, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
< section  name ="system.data.dataset"  type ="System.Configuration.NameValueFileSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"  restartOnExternalChanges ="false"   />
    
< section  name ="system.data.odbc"  type ="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
< section  name ="system.data.oledb"  type ="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
< section  name ="system.data.oracleclient"  type ="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
< section  name ="system.data.sqlclient"  type ="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
< section  name ="system.diagnostics"  type ="System.Diagnostics.SystemDiagnosticsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
< section  name ="system.runtime.remoting"  type ="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowLocation ="false"   />
    
< section  name ="system.windows.forms"  type ="System.Windows.Forms.WindowsFormsSection, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
< section  name ="windows"  type ="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowLocation ="false"   />
    
< sectionGroup  name ="system.xml.serialization"  type ="System.Xml.Serialization.Configuration.SerializationSectionGroup, System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      
< section  name ="schemaImporterExtensions"  type ="System.Xml.Serialization.Configuration.SchemaImporterExtensionsSection, System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="dateTimeSerialization"  type ="System.Xml.Serialization.Configuration.DateTimeSerializationSection, System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="xmlSerializer"  type ="System.Xml.Serialization.Configuration.XmlSerializerSection, System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"  requirePermission ="false"   />
    
</ sectionGroup >
    
< sectionGroup  name ="system.net"  type ="System.Net.Configuration.NetSectionGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      
< section  name ="authenticationModules"  type ="System.Net.Configuration.AuthenticationModulesSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="connectionManagement"  type ="System.Net.Configuration.ConnectionManagementSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="defaultProxy"  type ="System.Net.Configuration.DefaultProxySection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< sectionGroup  name ="mailSettings"  type ="System.Net.Configuration.MailSettingsSectionGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
        
< section  name ="smtp"  type ="System.Net.Configuration.SmtpSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
</ sectionGroup >
      
< section  name ="requestCaching"  type ="System.Net.Configuration.RequestCachingSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="settings"  type ="System.Net.Configuration.SettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="webRequestModules"  type ="System.Net.Configuration.WebRequestModulesSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
</ sectionGroup >
    
< sectionGroup  name ="system.transactions"  type ="System.Transactions.Configuration.TransactionsSectionGroup, System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" >
      
< section  name ="defaultSettings"  type ="System.Transactions.Configuration.DefaultSettingsSection, System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null"   />
      
< section  name ="machineSettings"  type ="System.Transactions.Configuration.MachineSettingsSection, System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null"  allowDefinition ="MachineOnly"  allowExeDefinition ="MachineOnly"   />
    
</ sectionGroup >
    
< sectionGroup  name ="system.web"  type ="System.Web.Configuration.SystemWebSectionGroup, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" >
      
< section  name ="anonymousIdentification"  type ="System.Web.Configuration.AnonymousIdentificationSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="authentication"  type ="System.Web.Configuration.AuthenticationSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="authorization"  type ="System.Web.Configuration.AuthorizationSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="browserCaps"  type ="System.Web.Configuration.HttpCapabilitiesSectionHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="clientTarget"  type ="System.Web.Configuration.ClientTargetSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="compilation"  type ="System.Web.Configuration.CompilationSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="customErrors"  type ="System.Web.Configuration.CustomErrorsSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="deployment"  type ="System.Web.Configuration.DeploymentSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineOnly"   />
      
< section  name ="deviceFilters"  type ="System.Web.Mobile.DeviceFiltersSection, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="globalization"  type ="System.Web.Configuration.GlobalizationSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="healthMonitoring"  type ="System.Web.Configuration.HealthMonitoringSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="hostingEnvironment"  type ="System.Web.Configuration.HostingEnvironmentSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="httpCookies"  type ="System.Web.Configuration.HttpCookiesSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="httpHandlers"  type ="System.Web.Configuration.HttpHandlersSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="httpModules"  type ="System.Web.Configuration.HttpModulesSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="httpRuntime"  type ="System.Web.Configuration.HttpRuntimeSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="identity"  type ="System.Web.Configuration.IdentitySection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="machineKey"  type ="System.Web.Configuration.MachineKeySection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="membership"  type ="System.Web.Configuration.MembershipSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="mobileControls"  type ="System.Web.UI.MobileControls.MobileControlsSection, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="pages"  type ="System.Web.Configuration.PagesSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="processModel"  type ="System.Web.Configuration.ProcessModelSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineOnly"  allowLocation ="false"   />
      
< section  name ="profile"  type ="System.Web.Configuration.ProfileSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="protocols"  type ="System.Web.Configuration.ProtocolsSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToWebRoot"   />
      
< section  name ="roleManager"  type ="System.Web.Configuration.RoleManagerSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="securityPolicy"  type ="System.Web.Configuration.SecurityPolicySection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="sessionPageState"  type ="System.Web.Configuration.SessionPageStateSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="sessionState"  type ="System.Web.Configuration.SessionStateSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="siteMap"  type ="System.Web.Configuration.SiteMapSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="trace"  type ="System.Web.Configuration.TraceSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="trust"  type ="System.Web.Configuration.TrustSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="urlMappings"  type ="System.Web.Configuration.UrlMappingsSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
< section  name ="webControls"  type ="System.Web.Configuration.WebControlsSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="webParts"  type ="System.Web.Configuration.WebPartsSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="webServices"  type ="System.Web.Services.Configuration.WebServicesSection, System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< section  name ="xhtmlConformance"  type ="System.Web.Configuration.XhtmlConformanceSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
< sectionGroup  name ="caching"  type ="System.Web.Configuration.SystemWebCachingSectionGroup, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" >
        
< section  name ="cache"  type ="System.Web.Configuration.CacheSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
        
< section  name ="outputCache"  type ="System.Web.Configuration.OutputCacheSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
        
< section  name ="outputCacheSettings"  type ="System.Web.Configuration.OutputCacheSettingsSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
        
< section  name ="sqlCacheDependency"  type ="System.Web.Configuration.SqlCacheDependencySection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  allowDefinition ="MachineToApplication"   />
      
</ sectionGroup >
    
</ sectionGroup >
    
< section  name ="system.webServer"  type ="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
    
< sectionGroup  name ="system.runtime.serialization"  type ="System.Runtime.Serialization.Configuration.SerializationSectionGroup, System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      
< section  name ="dataContractSerializer"  type ="System.Runtime.Serialization.Configuration.DataContractSerializerSection, System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
</ sectionGroup >
    
< sectionGroup  name ="system.serviceModel"  type ="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      
< section  name ="behaviors"  type ="System.ServiceModel.Configuration.BehaviorsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="bindings"  type ="System.ServiceModel.Configuration.BindingsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="client"  type ="System.ServiceModel.Configuration.ClientSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="comContracts"  type ="System.ServiceModel.Configuration.ComContractsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="commonBehaviors"  type ="System.ServiceModel.Configuration.CommonBehaviorsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"  allowDefinition ="MachineOnly"  allowExeDefinition ="MachineOnly"   />
      
< section  name ="diagnostics"  type ="System.ServiceModel.Configuration.DiagnosticSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="extensions"  type ="System.ServiceModel.Configuration.ExtensionsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="machineSettings"  type ="System.ServiceModel.Configuration.MachineSettingsSection, SMDiagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"  allowDefinition ="MachineOnly"  allowExeDefinition ="MachineOnly"   />
      
< section  name ="serviceHostingEnvironment"  type ="System.ServiceModel.Configuration.ServiceHostingEnvironmentSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="services"  type ="System.ServiceModel.Configuration.ServicesSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
</ sectionGroup >
    
< sectionGroup  name ="system.serviceModel.activation"  type ="System.ServiceModel.Activation.Configuration.ServiceModelActivationSectionGroup, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      
< section  name ="diagnostics"  type ="System.ServiceModel.Activation.Configuration.DiagnosticSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="net.pipe"  type ="System.ServiceModel.Activation.Configuration.NetPipeSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< section  name ="net.tcp"  type ="System.ServiceModel.Activation.Configuration.NetTcpSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
    
</ sectionGroup >
  
</ configSections >
  
< configProtectedData  defaultProvider ="RsaProtectedConfigurationProvider" >
    
< providers >
      
< add  name ="RsaProtectedConfigurationProvider"  type ="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  description ="Uses RsaCryptoServiceProvider to encrypt and decrypt"  keyContainerName ="NetFrameworkConfigurationKey"  cspProviderName =""  useMachineContainer ="true"  useOAEP ="false"   />
      
< add  name ="DataProtectionConfigurationProvider"  type ="System.Configuration.DpapiProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  description ="Uses CryptProtectData and CryptUnProtectData Windows APIs to encrypt and decrypt"  useMachineProtection ="true"  keyEntropy =""   />
    
</ providers >
  
</ configProtectedData >
  
< runtime  />
  
< connectionStrings >
    
< add  name ="LocalSqlServer"  connectionString ="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"  providerName ="System.Data.SqlClient"   />
  
</ connectionStrings >
  
< system.data >
    
< DbProviderFactories >
      
< add  name ="Odbc Data Provider"  invariant ="System.Data.Odbc"  description =".Net Framework Data Provider for Odbc"  type ="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< add  name ="OleDb Data Provider"  invariant ="System.Data.OleDb"  description =".Net Framework Data Provider for OleDb"  type ="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< add  name ="OracleClient Data Provider"  invariant ="System.Data.OracleClient"  description =".Net Framework Data Provider for Oracle"  type ="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< add  name ="SqlClient Data Provider"  invariant ="System.Data.SqlClient"  description =".Net Framework Data Provider for SqlServer"  type ="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   />
      
< add  name ="Microsoft SQL Server Compact Data Provider"  invariant ="System.Data.SqlServerCe.3.5"  description =".NET Framework Data Provider for Microsoft SQL Server Compact"  type ="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"   />
      
< add  name ="SQL Server CE Data Provider"  invariant ="Microsoft.SqlServerCe.Client"  description =".NET Framework Data Provider for Microsoft SQL Server 2005 Mobile Edition"  type ="Microsoft.SqlServerCe.Client.SqlCeClientFactory, Microsoft.SqlServerCe.Client, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"   />
    
</ DbProviderFactories >
  
</ system.data >
  
< system.web >
    
< processModel  autoConfig ="true"   />
    
< httpHandlers  />
    
< membership >
      
< providers >
        
< add  name ="AspNetSqlMembershipProvider"  type ="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  connectionStringName ="LocalSqlServer"  enablePasswordRetrieval ="false"  enablePasswordReset ="true"  requiresQuestionAndAnswer ="true"  applicationName ="/"  requiresUniqueEmail ="false"  passwordFormat ="Hashed"  maxInvalidPasswordAttempts ="5"  minRequiredPasswordLength ="7"  minRequiredNonalphanumericCharacters ="1"  passwordAttemptWindow ="10"  passwordStrengthRegularExpression =""   />
      
</ providers >
    
</ membership >
    
< profile >
      
< providers >
        
< add  name ="AspNetSqlProfileProvider"  connectionStringName ="LocalSqlServer"  applicationName ="/"  type ="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
</ providers >
    
</ profile >
    
< roleManager >
      
< providers >
        
< add  name ="AspNetSqlRoleProvider"  connectionStringName ="LocalSqlServer"  applicationName ="/"  type ="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
        
< add  name ="AspNetWindowsTokenRoleProvider"  applicationName ="/"  type ="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
</ providers >
    
</ roleManager >
  
</ system.web >
  
< system.serviceModel >
    
< extensions >
      
< behaviorExtensions >
        
< add  name ="persistenceProvider"  type ="System.ServiceModel.Configuration.PersistenceProviderElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
        
< add  name ="workflowRuntime"  type ="System.ServiceModel.Configuration.WorkflowRuntimeElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
        
< add  name ="enableWebScript"  type ="System.ServiceModel.Configuration.WebScriptEnablingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
        
< add  name ="webHttp"  type ="System.ServiceModel.Configuration.WebHttpElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
        
< add  name ="Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior"  type ="Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior, Microsoft.VisualStudio.Diagnostics.ServiceModelSink, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"   />
      
</ behaviorExtensions >
      
< bindingElementExtensions >
        
< add  name ="webMessageEncoding"  type ="System.ServiceModel.Configuration.WebMessageEncodingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
        
< add  name ="context"  type ="System.ServiceModel.Configuration.ContextBindingElementExtensionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
      
</ bindingElementExtensions >
      
< bindingExtensions >
        
< add  name ="wsHttpContextBinding"  type ="System.ServiceModel.Configuration.WSHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
        
< add  name ="netTcpContextBinding"  type ="System.ServiceModel.Configuration.NetTcpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
        
< add  name ="webHttpBinding"  type ="System.ServiceModel.Configuration.WebHttpBindingCollectionElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
        
< add  name ="basicHttpContextBinding"  type ="System.ServiceModel.Configuration.BasicHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"   />
      
</ bindingExtensions >
    
</ extensions >
    
< client >
      
< metadata >
        
< policyImporters >
          
< extension  type ="System.ServiceModel.Channels.ContextBindingElementImporter, system.workflowservices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"   />
        
</ policyImporters >
        
< wsdlImporters >
          
< extension  type ="System.ServiceModel.Channels.ContextBindingElementImporter, system.workflowservices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"   />
        
</ wsdlImporters >
      
</ metadata >
    
</ client >
    
< commonBehaviors >
      
< endpointBehaviors >
        
< Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior  />
      
</ endpointBehaviors >
      
< serviceBehaviors >
        
< Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior  />
      
</ serviceBehaviors >
    
</ commonBehaviors >
  
</ system.serviceModel >
</ configuration >

 

这个机器配置不用太关心,还是关心我们的重点web.config 因为这是我们每个项目都要用到的,做ASP.NET必学吧。

4. 配置文件的级别

 

配置级别

文件名

文件说明

服务器

Machine.config

Machine.config 文件包含服务器上所有 Web 应用程序的 ASP.NET 架构。此文件位于配置合并层次结构的顶层。

根 Web

Web.config

服务器的 Web.config 文件与 Machine.config 文件存储在同一个目录中,它包含大部分 system.web 配置节的默认值。运行时,此文件是从配置层次结构中的从上往下数第二层合并的。

网站

Web.config

特定网站的 Web.config 文件包含应用于该网站的设置,并向下继承到该站点的所有 ASP.NET 应用程序和子目录。

ASP.NET 应用程序根目录

Web.config

特定 ASP.NET 应用程序的 Web.config 文件位于该应用程序的根目录中,它包含应用于 Web 应用程序并向下继承到其分支中的所有子目录的设置。

ASP.NET 应用程序子目录

Web.config

应用程序子目录的 Web.config 文件包含应用于此子目录并向下继承到其分支中的所有子目录的设置。

客户端应用程序目录

应用程序名称.config

应用程序名称.config 文件包含 Windows 客户端应用程序(而非 Web 应用程序)的设置。

 
5.ASP.NET Web应用程序下的Web.config
需要对 一下信息进行了解(有详尽的注释):  configuration节点, configSections 节点, sectionGroup 节点, section节点
代码
<? xml version="1.0" ?>
< configuration >   <!--  所有的 ASP.NET 配置信息都驻留在 configuration 元素中.
此元素中的配置信息分为两个主区域:配置节处理程序声明区域和配置节设置区域 
-->
    
< configSections >
    
<!--  配置节处理程序声明区域  驻留在 configSections 元素内  -->
        
< sectionGroup  name ="system.web.extensions"  type ="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" >
            
< sectionGroup  name ="scripting"  type ="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" >
                
< section  name ="scriptResourceHandler"  type ="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  requirePermission ="false"  allowDefinition ="MachineToApplication" />
                
< sectionGroup  name ="webServices"  type ="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" >
                
<!--  节处理程序是用来实现 ConfigurationSection 接口的 .NET Framework 类
                    学过Java的就知道,相当于:ConfigurationSection config = new ScriptingWebServicesSectionGroup() 我的理解是这样的,不对请多多指教,最好留言说明!
                
-->
                    
< section  name ="jsonSerialization"  type ="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  requirePermission ="false"  allowDefinition ="Everywhere" />
                    
< section  name ="profileService"  type ="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  requirePermission ="false"  allowDefinition ="MachineToApplication" />
                    
< section  name ="authenticationService"  type ="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  requirePermission ="false"  allowDefinition ="MachineToApplication" />
                    
< section  name ="roleService"  type ="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  requirePermission ="false"  allowDefinition ="MachineToApplication" />
                
</ sectionGroup >
            
</ sectionGroup >
        
</ sectionGroup >
                
<!--  sectionGroup 元素表示要应用配置设置的命名空间  -->
    
</ configSections >
    
< appSettings />
        
<!--  此节用于定义应用程序设置项。对一些不确定设置,还可以让用户根据自己实际情况自己设置 ;使用add添加并设置属性  -->
    
< connectionStrings >
        
< add  connectionString ="server=.;userid=sa;pwd=;databaseName=Northwind"  name ="Northwind" />
    
</ connectionStrings >
    
< system.web >
        
<!--  
            设置 compilation debug="true" 可将调试符号插入
            已编译的页面中。但由于这会 
            影响性能,因此只在开发过程中将此值 
            设置为 true。
        
-->
        
< compilation  debug ="true"  defaultLanguage ="C#" > <!--  允许调试(debug=“false”不允许调试 一般是交于客户的时候才设置该选项) 
        默认语言是C#(默认语言可以不用配置 默认了是C#) 
-->
            
< assemblies >
                
< add  assembly ="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                
< add  assembly ="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                
< add  assembly ="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                
< add  assembly ="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            
</ assemblies >
        
</ compilation >
        
<!--
            通过 <authentication> 节可以配置 ASP.NET 用来 
            识别进入用户的
            安全身份验证模式。 
        
-->
        
< authentication  mode ="Windows" />
        
        
<!--
                <authentication   mode= "Forms "> 
                <forms   name= ".ASPXUSERDEMO "   loginUrl= "Login.aspx "   protection= "All "   timeout="30 "/> 
                </authentication> 
                <authorization> 
                <deny   users= "? "/> 
                </authorization> 
                
                I.Windows:   使用IIS验证方式 
                II.Forms:   使用基于窗体的验证方式 
                III.Passport:   采用Passport   cookie验证模式 
                IV.None:   不采用任何验证方式 
                
                里面内嵌Forms节点的属性涵义: 
                I.Name:   指定完成身份验证的Http   cookie的名称. 
                II.LoginUrl:   如果未通过验证或超时后重定向的页面URL,一般为登录页面,让用户重新登录 
                III.Protection:   指定   cookie数据的保护方式. 
                可设置为:   All   None   Encryption   Validation四种保护方式 
                a.   All表示加密数据,并进行有效性验证两种方式 
                b.   None表示不保护Cookie. 
                c.   Encryption表示对Cookie内容进行加密 
                d.   validation表示对Cookie内容进行有效性验证 
                IV.   TimeOut:   指定Cookie的失效时间.   超时后要重新登录. 
                        
        
-->
        
<!--
            如果在执行请求的过程中出现未处理的错误,
            则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
            开发人员通过该节可以配置
            要显示的 html 错误页
            以代替错误堆栈跟踪。

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        
        这个很重要,我昨天复试进入企业第一个问题就是这个,我答的很勉强,不过很顺利,现在进入工作了。
        customErrors mode 有三种状态:
         具有On,Off,RemoteOnly   3种状态:
         
         On表示始终显示自定义的信息;   
         Off表示始终显示详细的asp.net错误信息;   
         RemoteOnly表示只对不在本地Web服务器上运行的用户显示自定义信息.
         
         defaultRedirect:   用于出现错误时重定向的URL地址.   是可选的
         statusCode:   指明错误状态码,表明一种特定的出错状态.  
        
-->
        
< pages >
            
< controls >
                
< add  tagPrefix ="asp"  namespace ="System.Web.UI"  assembly ="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                
< add  tagPrefix ="asp"  namespace ="System.Web.UI.WebControls"  assembly ="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            
</ controls >
        
</ pages >
        
< httpHandlers >
            
< remove  verb ="*"  path ="*.asmx" />
            
< add  verb ="*"  path ="*.asmx"  validate ="false"  type ="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            
< add  verb ="*"  path ="*_AppService.axd"  validate ="false"  type ="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            
< add  verb ="GET,HEAD"  path ="ScriptResource.axd"  type ="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"  validate ="false" />
        
</ httpHandlers >
        
< httpModules >
            
< add  name ="ScriptModule"  type ="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        
</ httpModules >
    
</ system.web >
    
< system.codedom >
        
< compilers >
            
< compiler  language ="c#;cs;csharp"  extension =".cs"  warningLevel ="4"  type ="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
                
< providerOption  name ="CompilerVersion"  value ="v3.5" />
                
< providerOption  name ="WarnAsError"  value ="false" />
            
</ compiler >
        
</ compilers >
    
</ system.codedom >
    
<!--  
        在 Internet 信息服务 7.0 下运行 ASP.NET AJAX 需要 system.webServer
        节。对早期版本的 IIS 来说则不需要此节。
    
-->
    
< system.webServer >
        
< validation  validateIntegratedModeConfiguration ="false" />
        
< modules >
            
< remove  name ="ScriptModule" />
            
< add  name ="ScriptModule"  preCondition ="managedHandler"  type ="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        
</ modules >
        
< handlers >
            
< remove  name ="WebServiceHandlerFactory-Integrated" />
            
< remove  name ="ScriptHandlerFactory" />
            
< remove  name ="ScriptHandlerFactoryAppServices" />
            
< remove  name ="ScriptResource" />
            
< add  name ="ScriptHandlerFactory"  verb ="*"  path ="*.asmx"  preCondition ="integratedMode"  type ="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            
< add  name ="ScriptHandlerFactoryAppServices"  verb ="*"  path ="*_AppService.axd"  preCondition ="integratedMode"  type ="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            
< add  name ="ScriptResource"  preCondition ="integratedMode"  verb ="GET,HEAD"  path ="ScriptResource.axd"  type ="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        
</ handlers >
    
</ system.webServer >
    
< runtime >
        
< assemblyBinding  xmlns ="urn:schemas-microsoft-com:asm.v1" >
            
< dependentAssembly >
                
< assemblyIdentity  name ="System.Web.Extensions"  publicKeyToken ="31bf3856ad364e35" />
                
< bindingRedirect  oldVersion ="1.0.0.0-1.1.0.0"  newVersion ="3.5.0.0" />
            
</ dependentAssembly >
            
< dependentAssembly >
                
< assemblyIdentity  name ="System.Web.Extensions.Design"  publicKeyToken ="31bf3856ad364e35" />
                
< bindingRedirect  oldVersion ="1.0.0.0-1.1.0.0"  newVersion ="3.5.0.0" />
            
</ dependentAssembly >
        
</ assemblyBinding >
    
</ runtime >
</ configuration >

 更多配置(参考):

  /Files/Simcoder/Web.config配置详解.txt

你可能感兴趣的:(config)