共用方式為


IHttpSessionState.CodePage 屬性

定義

取得或設定目前工作階段的字碼頁識別項。

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

屬性值

Int32

目前工作階段的字碼頁識別項。

範例

下列程式碼範例會 CodePage 實作 介面的 IHttpSessionState 屬性,以取得和設定目前回應的編碼方式。

//
// 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

備註

字元集 (字碼頁) 用來解譯多位元組字元資料、判斷字元值,以及排序次序。 字碼頁設定僅適用于多位元組字元資料,不適用於 Unicode 字元資料。

此屬性 CodePage 僅供與舊版 ASP 相容。 如果您不需要維持與 ASP 頁面的回溯相容性,請改用 CodePage 屬性的 ContentEncoding 屬性。

適用於

另請參閱