Bagikan melalui


IHttpSessionState.CodePage Properti

Definisi

Mendapatkan atau mengatur pengidentifikasi halaman kode untuk sesi saat ini.

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

Nilai Properti

Pengidentifikasi halaman kode untuk sesi saat ini.

Contoh

Contoh kode berikut mengimplementasikan CodePage properti IHttpSessionState antarmuka untuk mendapatkan dan mengatur pengodean untuk respons saat ini.

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

Keterangan

Kumpulan karakter (halaman kode) digunakan untuk menginterpretasikan data karakter multi-byte, menentukan nilai karakter, dan oleh karena itu urutan pengurutan. Pengaturan halaman kode hanya berlaku untuk data karakter multi-byte, bukan untuk data karakter Unicode.

Properti ini CodePage disediakan untuk kompatibilitas hanya dengan versi ASP yang lebih lama. Jika Anda tidak perlu mempertahankan kompatibilitas mundur dengan halaman ASP, gunakan CodePage properti properti sebagai gantinya ContentEncoding .

Berlaku untuk

Lihat juga