Share via


ISessionIDManager.GetSessionID(HttpContext) 메서드

정의

현재 HTTP 요청의 컨텍스트에서 세션 식별자를 가져옵니다.

public:
 System::String ^ GetSessionID(System::Web::HttpContext ^ context);
public string GetSessionID (System.Web.HttpContext context);
abstract member GetSessionID : System.Web.HttpContext -> string
Public Function GetSessionID (context As HttpContext) As String

매개 변수

context
HttpContext

HTTP 요청(예: HttpContextRequest 속성)을 처리하는 데 사용되는 서버 개체를 참조하는 Response 개체입니다.

반환

HTTP 요청과 함께 전송된 현재 세션 식별자입니다.

예제

다음 코드 예제에서는 부분적으로 구현 된 GetSessionID 메서드. 사용자 지정 세션 ID 관리자에서 쿠키 없는 세션 식별자를 지 원하는 경우에 전송 및 ISAPI 필터와 같은 URL에서 세션 식별자를 검색에 대 한 솔루션을 구현 하는 것이 해야 합니다.

public string GetSessionID(HttpContext context)
{
  string id = null;

  if (pConfig.Cookieless == HttpCookieMode.UseUri)
  {
    // Retrieve the SessionID from the URI.
  }
  else
  {
    id = context.Request.Cookies[pConfig.CookieName].Value;
  }      

  // Verify that the retrieved SessionID is valid. If not, return null.

  if (!Validate(id))
    id = null;

  return id;
}
Public Function GetSessionID(context As HttpContext) As String _
  Implements ISessionIDManager.GetSessionID

  Dim id As String = Nothing

  If pConfig.Cookieless = HttpCookieMode.UseUri Then
    ' Retrieve the SessionID from the URI.
  Else
    id = context.Request.Cookies(pConfig.CookieName).Value
  End If    

  ' Verify that the retrieved SessionID is valid. If not, return Nothing.

  If Not Validate(id) Then _
    id = Nothing

  Return id
End Function

설명

GetSessionID 메서드를 호출 합니다 SessionStateModule 중 합니다 HttpApplication.AcquireRequestStateHttpApplication.EndRequest 이벤트. 반환 된 HTTP 요청에서 유효한 세션 식별자를 검색할 수 없으면, null합니다. 경우는 SessionStateModule 수신 null 에서 GetSessionID 메서드를 호출는 CreateSessionID 메서드를 새 세션에 대 한 새 세션 식별자를 가져옵니다.

가능한 값을 반환한 경우에 CreateSessionID 구현에는 HTTP 응답 또는 요청에 잘못 된 문자가 포함 되어 있습니다.를 사용 해야 합니다 UrlEncode 세션 id 값 인코딩 방법에 SaveSessionID 메서드 구현 하며 UrlDecode 메서드를 디코딩하는 데 세션 식별자 값에 GetSessionID 메서드 구현 합니다.

적용 대상

추가 정보