Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the code-page identifier for the current session.
public:
property int CodePage { int get(); void set(int value); };
public int CodePage { get; set; }
member this.CodePage : int with get, set
Public Property CodePage As Integer
The code-page identifier for the current session.
The following code example implements the CodePage property of the IHttpSessionState interface to get and set the encoding for the current response.
//
// Session.CodePage exists only to support legacy ASP compatibility. ASP.NET developers should use
// Response.ContentEncoding instead.
//
public int CodePage
{
get
{
if (HttpContext.Current != null)
return HttpContext.Current.Response.ContentEncoding.CodePage;
else
return Encoding.Default.CodePage;
}
set
{
if (HttpContext.Current != null)
HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding(value);
}
}
'
' Session.CodePage exists only to support legacy ASP compatibility. ASP.NET developers should use
' Response.ContentEncoding instead.
'
Public Property CodePage As Integer Implements IHttpSessionState.CodePage
Get
If Not HttpContext.Current Is Nothing Then
Return HttpContext.Current.Response.ContentEncoding.CodePage
Else
Return Encoding.Default.CodePage
End If
End Get
Set
If Not HttpContext.Current Is Nothing Then _
HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding(value)
End Set
End Property
A character set (code page) is used to interpret multi-byte character data, determining character value, and therefore sort order. Code-page settings apply only to multi-byte character data, not to Unicode character data.
This CodePage property is provided for compatibility with earlier versions of ASP only. If you do not need to maintain backward compatibility with ASP pages, use the CodePage property of the ContentEncoding property instead.
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in