SessionIDManager.CreateSessionID メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SessionIDManager.CreateSessionID メソッドの意味・解説 

SessionIDManager.CreateSessionID メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

セッション一意セッション識別子作成します

名前空間: System.Web.SessionState
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Overridable Function
 CreateSessionID ( _
    context As HttpContext _
) As String
Dim instance As SessionIDManager
Dim context As HttpContext
Dim returnValue As String

returnValue = instance.CreateSessionID(context)
public virtual string CreateSessionID (
    HttpContext context
)
public:
virtual String^ CreateSessionID (
    HttpContext^ context
)
public String CreateSessionID (
    HttpContext context
)
public function CreateSessionID (
    context : HttpContext
) : String

パラメータ

context

Request プロパティResponse プロパティなどの HTTP 要求処理するためのサーバー オブジェクト参照する現在の HttpContext オブジェクト

戻り値
一意セッション識別子

解説解説
使用例使用例

SessionIDManager クラス継承しCreateSessionID メソッドおよび Validate メソッドを、Guid提供するメソッドとそれを SessionID として検証するメソッドオーバーライドするクラスコード例次に示します

Imports System
Imports System.Configuration
Imports System.Web.Configuration
Imports System.Web
Imports System.Web.SessionState


Namespace Samples.AspNet.Session

  Public Class GuidSessionIDManager
    Inherits SessionIDManager

    Public Overrides Function
 CreateSessionID(context As HttpContext) As
 String
      Return Guid.NewGuid().ToString()
    End Function

    Public Overrides Function
 Validate(id As String) As
 Boolean
      Try
        Dim testGuid As Guid = New
 Guid(id)

        If id = testGuid.ToString() Then _
          Return True
      Catch
      
      End Try

      Return False
    End Function

  End Class

End Namespace
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.SessionState;


namespace Samples.AspNet.Session
{

  public class GuidSessionIDManager : SessionIDManager
  {

    public override string CreateSessionID(HttpContext
 context)
    {
      return Guid.NewGuid().ToString();
    }


    public override bool Validate(string
 id)
    {
      try
      {
        Guid testGuid = new Guid(id);

        if (id == testGuid.ToString())
          return true;
      }
      catch
      {
      }

      return false;
    }
  }
}

この例で示されているカスタム クラス使用するには、次の例に示すように sessionState 要素 (ASP.NET 設定スキーマ) 要素の sessionIDManagerType 属性構成します

<sessionState
  Mode="InProc"
  stateConnectionString="tcp=127.0.0.1:42424"
  stateNetworkTimeout="10"
  sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI"
  sqlCommandTimeout="30"
  customProvider=""
  cookieless="false"
  regenerateExpiredSessionId="false"
  timeout="20"
  sessionIDManagerType="Your.ID.Manager.Type,
    CustomAssemblyNameInBinFolder"
/>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SessionIDManager クラス
SessionIDManager メンバ
System.Web.SessionState 名前空間
その他の技術情報
ASP.NETセッション状態



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

SessionIDManager.CreateSessionID メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SessionIDManager.CreateSessionID メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS