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 ページとの下位互換性を維持する必要がない場合は、代わりにプロパティのプロパティをContentEncoding使用CodePageします。

適用対象

こちらもご覧ください