Bagikan melalui


globalization Element (ASP.NET Settings Schema)

Configures the globalization settings for an application.

<configuration> Element
  system.web Element (ASP.NET Settings Schema)
    globalization Element (ASP.NET Settings Schema)

<globalization
    enableClientBasedCulture="true|false"
    requestEncoding="any valid encoding string"
    responseEncoding="any valid encoding string"
    fileEncoding="any valid encoding string"

    responseHeaderEncoding = "any valid encoding string" 
    resourceProviderFactoryType = string
    enableBestFitResponseEncoding = "true|false"

    culture="any valid culture string"
    uiCulture="any valid culture string"/>

Attributes and Elements

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

Attributes

Attribute

Description

culture

Optional attribute.

Specifies the default culture for processing incoming Web requests.

For valid culture strings, see System.Globalization.CultureInfo.

This attribute can also be set to auto.

enableClientBasedCulture

Optional attribute.

This attribute is not in use at this time.

fileEncoding

Optional attribute.

Specifies the default encoding for .aspx, .asmx, and .asax file parsing. Unicode and UTF-8 files that are saved with the byte order mark prefix are automatically recognized, regardless of the value for this attribute.

requestEncoding

Optional attribute.

Specifies the assumed encoding of each incoming request, including posted data and the query string.

If the request comes with a request header that contains an Accept-Charset attribute, it overrides this attribute in the configuration.

The default encoding is UTF-8, which is specified in the globalization section in the Machine.config file that was created when the .NET Framework was installed. If request encoding is not specified in a Machine.config or Web.config file, encoding defaults to the Regional Options locale setting for the computer.

In single-server applications, this attribute and the responseEncoding attribute should be the same. For the less common case (multiple-server applications where the default server encodings are different), you can vary the request and response encoding by using local Web.config files.

responseEncoding

Optional attribute.

Specifies the content encoding of responses.

The default encoding is UTF-8, which is specified in the globalization section in the Machine.config file that was created when the .NET Framework was installed. If response encoding is not specified in a Machine.config or Web.config file, encoding defaults to the Regional Options locale setting for the computer.

In single-server applications, this attribute and the responseEncoding attribute should be the same. For the less common case (multiple-server applications where the default server encodings are different), you can vary the request and response encoding by using local Web.config files.

uiCulture

Optional attribute.

Specifies the default culture for processing locale-dependent resource searches. For valid culture strings, see System.Globalization.CultureInfo.

This attribute can also be set to auto.

Child Elements

None.

Parent Elements

Element

Description

configuration

Specifies the 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 section.

Remarks

If the server or application fileEncoding attribute setting is configured to use UTF-16 and UTF-16 is not the encoding that is used for an .aspx page in the scope of the configuration file, the output that is sent to the client browser will be corrupted and might possibly display the source code of the page. Make sure that the configured fileEncoding value matches the encoding that is being used in the page.

Default Configuration

The following default globalization 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 application.

<globalization requestEncoding="utf-8" 
               responseEncoding="utf-8" 
               fileEncoding="" 
               culture="" 
               uiCulture="" 
               enableClientBasedCulture="false" 
               responseHeaderEncoding="utf-8" 
               resourceProviderFactoryType="" 
               enableBestFitResponseEncoding="false" />

Example

The following code example demonstrates how to specify the default request and response encoding for an ASP.NET application.

<configuration>
   <system.web>
      <globalization 
         requestEncoding="iso-8859-1"
         responseEncoding="iso-8859-1"/>
   </system.web>
</configuration>

Element Information

Configuration section handler

System.Web.Configuration.GlobalizationSection

Configuration member

SystemWebSectionGroup.Globalization

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory–level Web.config

Requirements

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

The Microsoft .NET Framework version 1.0, 1.1, or 2.0

Microsoft Visual Studio 2003 or Visual Studio 2005

See Also

Tasks

How to: Lock ASP.NET Configuration Settings

Concepts

Encoding Base Types

ASP.NET Configuration Overview

ASP.NET Web Server Controls and Browser Capabilities

Securing ASP.NET Configuration

ASP.NET Configuration Scenarios

Reference

system.web Element (ASP.NET Settings Schema)

<configuration> Element

System.Configuration

System.Web.Configuration

Other Resources

ASP.NET Configuration Files

ASP.NET Configuration Settings

General Configuration Settings (ASP.NET)

ASP.NET Configuration API