다음을 통해 공유


clear Element for providers for sessionState (ASP.NET Settings Schema) 

Removes all references to inherited session-state store providers, allowing only the session-state store providers that are added by the current add element.

This element is new in the .NET Framework version 2.0.

<clear/>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

None.

Child Elements

None.

Parent Elements

Element Description

configuration

Specifies the required root element in every configuration file that is used by the common language runtime and the .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration settings in a configuration file and contains configuration elements that configure ASP.NET Web applications and control how the applications behave.

sessionState

Configures session-state settings for the current application.

providers

Contains a collection of custom session-state store providers.

Remarks

The clear element removes all references to inherited session-state store providers in the providers element, allowing only the session-state store providers that are added by succeeding add elements.

The providers element contains a collection of custom session state-store providers. The custom session-state store provider must inherit from the SessionStateStoreProviderBase class.

For information about accessing and modifying configuration values for the sessionState element in application code, see ProviderSettingsCollection and Providers.

Default Configuration

The following default providers element is not explicitly configured in the Machine.config file or in the root Web.config file. However, it is the default configuration that is returned by the application.

<sessionState
   <!-- Attribute settings. -->
>
   <providers>
      <clear />
   </providers>
</sessionState>

Example

The following code example shows how to configure the Web.config file for an ASP.NET application to use a custom session-state store provider. The example clears any existing instances of session-state store providers by using the clear element, before adding the custom instance of the session-state store provider. For information about implementing a session-state store provider and a sample provider, see Implementing a Session-State Store Provider.

<configuration>
  <connectionStrings>
    <add name="OdbcSessionServices" connectionString="DSN=SessionState;" />
  </connectionStrings>

  <system.web>
    <sessionState 
      cookieless="true"
      regenerateExpiredSessionId="true" 
      mode="Custom"
      customProvider="OdbcSessionProvider">
      <providers>
        <clear />
        <add name="OdbcSessionProvider"
          type="Samples.AspNet.Session.OdbcSessionStateStore"
          connectionStringName="OdbcSessionServices" 
          writeExceptionsToEventLog="false" />
      </providers>
    </sessionState>
  </system.web>
</configuration>

Element Information

Configuration section handler

SessionStateSection

Configuration member

Clear

Providers

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Requirements

Microsoft Internet Information Services (IIS) version 5.0, 5.1, or 6.0

The .NET Framework version 2.0

Microsoft Visual Studio 2003 or Visual Studio 2005

See Also

Tasks

How to: Configure Specific Directories Using Location Settings
How to: Lock ASP.NET Configuration Settings

Reference

providers Element for sessionState (ASP.NET Settings Schema)
add Element for providers for sessionState (ASP.NET Settings Schema)
remove Element for providers for sessionState (ASP.NET Settings Schema)
providers Element for sessionState (ASP.NET Settings Schema)
sessionState Element (ASP.NET Settings Schema)
system.web Element (ASP.NET Settings Schema)
configuration Element (General Settings Schema)
System.Configuration
System.Web.Configuration
SessionStateSection
ProviderSettingsCollection
Providers
SessionStateStoreProviderBase

Concepts

Implementing a Session-State Store Provider
Securing Session State
ASP.NET Configuration File Hierarchy and Inheritance
Securing ASP.NET Configuration
ASP.NET Configuration Scenarios

Other Resources

Protected Configuration
General Configuration Settings (ASP.NET)
ASP.NET Configuration Settings
Configuring ASP.NET Applications
ASP.NET Configuration API