This documentation is archived and is not being maintained.

GlobalizationSection.FileEncoding Property

Gets or sets a value specifying the default encoding for .aspx, .asmx, and .asax file parsing.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

public Encoding FileEncoding { get; set; }

Property Value

Type: System.Text.Encoding
The default encoding value.

The FileEncoding property specifies the default encoding that is used to interpret the data that is included in the .aspx, .asmx, and .asax file types. If the file encoding is specified in the Web.config file, the actual file must be saved in the same encoding. Unicode files and UTF-8 files that are saved with the byte order mark prefix IsByteOrdered property are automatically recognized regardless of the value of the FileEncoding.

If the FileEncoding property setting for the server or application is configured to use UTF-16, and if 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 is corrupted. For this reason, ensure that the configured FileEncoding value matches the encoding that is used in the .aspx page.

The following code example demonstrates how to use the FileEncoding property. This code example is part of a larger example provided for the GlobalizationSection class.

// Display FileEncoding property.
Console.WriteLine("FileEncoding: {0}", 

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.