Condividi tramite


remove Element for namespaces for pages (ASP.NET Settings Schema)

Removes a reference to an inherited namespace from the collection of namespaces.

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

<remove 
   namespace="namespace"
/>

Attributes and Elements

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

Attributes

Attribute Description

namespace

Required String attribute.

The namespace to remove from the pre-compilation import directive collection (for example, "System.Web").

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.

pages

Defines page-specific configuration settings, such as global ASP.NET directives, for pages and controls that are within the scope of the configuration file.

namespaces

Defines a collection of import directives to use during assembly pre-compilation.

Remarks

The remove element removes a reference to an inherited namespace from the collection of namespaces that is stored in the namspaces element.

The namespaces element defines a collection of import directives to use during assembly pre-compilation. This attribute corresponds to the @ Import directive on an ASP.NET page. The @ Import directive lets you specify namespaces that are automatically imported into all pages of an application.

Default Configuration

The following default namespaces element is configured in the root Web.config file. You can remove any of these namespaces from the collection by using the remove element in the Web.config file for an application.

<pages>
   <namespaces>
      <add namespace="System" />
      <add namespace="System.Collections" />
      <add namespace="System.Collections.Specialized" />
      <add namespace="System.Configuration" />
      <add namespace="System.Text" />
      <add namespace="System.Text.RegularExpressions" />
      <add namespace="System.Web" />
      <add namespace="System.Web.Caching" />
      <add namespace="System.Web.SessionState" />
      <add namespace="System.Web.Security" />
      <add namespace="System.Web.Profile" />
      <add namespace="System.Web.UI" />
      <add namespace="System.Web.UI.WebControls" />
      <add namespace="System.Web.UI.WebControls.WebParts" />
      <add namespace="System.Web.UI.HtmlControls" />
   </namespaces>
   <!-- Other elements -->
</pages>

Example

The following code example shows how to remove an inherited namespace from pre-compilation.

<configuration>
   <system.web>
      <pages>
         <namespaces>
            <remove namespace="System.Text.RegularExpressions"/>
         </namespaces>
      </pages>
   </system.web>
</configuration>

Element Information

Configuration section Handler

PagesSection

Configuration member

Namespaces

Remove

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory–level Web.config

Requirements

icrosoft 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

namespaces Element for pages (ASP.NET Settings Schema)
add Element for namespaces for pages (ASP.NET Settings Schema)
clear Element for namespaces for pages (ASP.NET Settings Schema)
tagMapping Element for pages (ASP.NET Settings Schema)
controls Element for pages (ASP.NET Settings Schema)
pages Element (ASP.NET Settings Schema)
system.web Element (ASP.NET Settings Schema)
configuration Element (General Settings Schema)
@ Page
@ Import
System.Configuration
System.Web.Configuration
Namespaces
NamespaceCollection
PagesSection

Concepts

ASP.NET Configuration File Hierarchy and Inheritance
Securing ASP.NET Configuration

Other Resources

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