Web Forms configuration files, named Web.config, provide settings for every Web Forms page in the same directory as the configuration file. The settings are usually also inherited by subdirectories. Each file can contain a globalization section in which you can specify default encodings and cultures. Values are valid if they are accepted by the related Encoding and CultureInfo classes. For more information on the contents of the Globalization section, see <globalization> Element. For general information on Web.config files, see ASP.NET Configuration.
The Web.config file is case-sensitive, so specifying a value for "FileEncoding" will not have the desired effect, but specifying a value for "fileEncoding" will. For more information, see Format of ASP.NET Configuration Files.
To edit the Web.config file
- Set the values of fileEncoding, requestEncoding and responseEncoding to specify the way in which .aspx files, request data and response data are encoded. For more information on encoding values, see Selecting an Encoding for Web Forms Globalization
If the file encoding is specified in the Web.config file, the actual file must be saved in the same encoding. To select an encoding different from the system default, use the Advanced Save Options dialog box (available on the File menu).
- Set the values of culture and uiCulture. For more information on culture values, see Setting the Culture and UI Culture for Web Forms Globalization.
<configuration>
<system.web>
<globalization
fileEncoding="utf-8"
requestEncoding="utf-8"
responseEncoding="utf-8"
culture="en-US"
uiCulture="de-DE"
/>
</system.web>
</configuration> Note The attributes of the globalization section in the Web.config file can also be specified in the @ Page directive (with the exception of fileEncoding, which can only be specified in Web.config because it applies to the file itself). Settings in the Page directive are only valid for a specific page and override the settings of the Web.config file.
See Also
Globalizing Web Forms Pages