SiteMapProvider.FindSiteMapNode 메서드

정의

파생 클래스에서 재정의되면 페이지를 나타내는 SiteMapNode 개체를 검색합니다.

오버로드

FindSiteMapNode(String)

파생 클래스에서 재정의되면 지정된 URL의 페이지를 나타내는 SiteMapNode 개체를 검색합니다.

FindSiteMapNode(HttpContext)

지정한 SiteMapNode 개체를 사용하여 현재 요청된 페이지를 나타내는 HttpContext 개체를 검색합니다.

FindSiteMapNode(String)

파생 클래스에서 재정의되면 지정된 URL의 페이지를 나타내는 SiteMapNode 개체를 검색합니다.

public:
 abstract System::Web::SiteMapNode ^ FindSiteMapNode(System::String ^ rawUrl);
public abstract System.Web.SiteMapNode FindSiteMapNode (string rawUrl);
abstract member FindSiteMapNode : string -> System.Web.SiteMapNode
Public MustOverride Function FindSiteMapNode (rawUrl As String) As SiteMapNode

매개 변수

rawUrl
String

SiteMapNode를 검색할 페이지를 식별하는 URL입니다.

반환

rawURL로 식별된 페이지를 나타내는 SiteMapNode이거나, 그렇지 않고 일치하는 SiteMapNode가 없거나 보안 트리밍이 설정되어 있으며 현재 사용자에 대해 SiteMapNode가 반환될 수 없으면 null입니다.

예제

다음 코드 예제를 구현 하는 방법에 설명 합니다 FindSiteMapNode 메서드를 구현 하는 클래스에서 SiteMapProvider 클래스입니다. 합니다 SimpleTextSiteMapProvider 라는 도우미 메서드를 사용 하 여 FindUrl에서 현재 표시 된 페이지의 URL을 가져오려면는 HttpContext 개체입니다.

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 SiteMapProvider 클래스입니다.

// Implement the FindSiteMapNode method.
public override SiteMapNode FindSiteMapNode(string rawUrl)
{

  // Does the root node match the URL?
  if (RootNode.Url == rawUrl)
  {
    return RootNode;
  }
  else
  {
    SiteMapNode candidate = null;
    // Retrieve the SiteMapNode that matches the URL.
    lock (this)
    {
      candidate = GetNode(siteMapNodes, rawUrl);
    }
    return candidate;
  }
}
' Implement the FindSiteMapNode method.
Public Overrides Function FindSiteMapNode(ByVal rawUrl As String) As SiteMapNode
  ' Does the root node match the URL?
  If RootNode.Url = rawUrl Then
    Return RootNode
  Else
    Dim candidate As SiteMapNode = Nothing
    ' Retrieve the SiteMapNode that matches the URL.
    SyncLock Me
      candidate = GetNode(siteMapNodes, rawUrl)
    End SyncLock
    Return candidate
  End If
End Function 'FindSiteMapNode
private SiteMapNode GetNode(ArrayList list, string url)
{
  for (int i = 0; i < list.Count; i++)
  {
    DictionaryEntry item = (DictionaryEntry)list[i];
    if ((string)item.Key == url)
      return item.Value as SiteMapNode;
  }
  return null;
}

// Get the URL of the currently displayed page.
private string FindCurrentUrl()
{
  try
  {
    // The current HttpContext.
    HttpContext currentContext = HttpContext.Current;
    if (currentContext != null)
    {
      return currentContext.Request.RawUrl;
    }
    else
    {
      throw new Exception("HttpContext.Current is Invalid");
    }
  }
  catch (Exception e)
  {
    throw new NotSupportedException("This provider requires a valid context.",e);
  }
}
Private Function GetNode(ByVal list As ArrayList, ByVal url As String) As SiteMapNode
  Dim i As Integer
  For i = 0 To list.Count - 1
    Dim item As DictionaryEntry = CType(list(i), DictionaryEntry)
    If CStr(item.Key) = url Then
      Return CType(item.Value, SiteMapNode)
    End If
  Next i
  Return Nothing
End Function 'GetNode


' Get the URL of the currently displayed page.
Private Function FindCurrentUrl() As String
  Try
    ' The current HttpContext.
    Dim currentContext As HttpContext = HttpContext.Current
    If Not (currentContext Is Nothing) Then
      Return currentContext.Request.RawUrl
    Else
      Throw New Exception("HttpContext.Current is Invalid")
    End If
  Catch e As Exception
    Throw New NotSupportedException("This provider requires a valid context.", e)
  End Try
End Function 'FindCurrentUrl

설명

파생 된 클래스는 SiteMapProvider 추상 클래스를 구현 해야 FindSiteMapNode 메서드.

제공 된 URL에는 가상 또는 절대 URL을 수 있습니다. 같은 애플리케이션에 상대적인 구문을 사용 하는 URL 일 수도 ~/apprelativedirectory합니다. 모든 구현 했는지를 FindSiteMapNode 메서드 구문 분석 하 고 애플리케이션에 상대적인 구문을 제대로 처리 합니다.

합니다 XmlSiteMapProvider 의 URL을 사용 하 여 ASP.NET에 대 한 기본 사이트 맵 공급자가 클래스를 SiteMapNode 개체 클래스를 유지 관리 하는 다양 한 컬렉션의 키로 합니다. 따라서 경우는 SiteMapNode URL을 제공 사이트 맵 공급자의 범위 내에서 고유 해야 합니다. 식별 하는 고유 식별자가 생성 없는 URL이 제공 하는 경우는 SiteMapNode합니다.

구현자 참고

재정의 하는 경우는 FindSiteMapNode(String) 파생된 클래스에서 메서드 해야 모든 자식 공급자에 검색을 확장 하는 경우는 SiteMapNode 공급자 자식 공급자가 지 원하는 및의 현재 사이트 맵 공급자가는 URL과 일치 하는 개체를 찾을 수 없습니다.

추가 정보

적용 대상

FindSiteMapNode(HttpContext)

지정한 SiteMapNode 개체를 사용하여 현재 요청된 페이지를 나타내는 HttpContext 개체를 검색합니다.

public:
 virtual System::Web::SiteMapNode ^ FindSiteMapNode(System::Web::HttpContext ^ context);
public virtual System.Web.SiteMapNode FindSiteMapNode (System.Web.HttpContext context);
abstract member FindSiteMapNode : System.Web.HttpContext -> System.Web.SiteMapNode
override this.FindSiteMapNode : System.Web.HttpContext -> System.Web.SiteMapNode
Public Overridable Function FindSiteMapNode (context As HttpContext) As SiteMapNode

매개 변수

context
HttpContext

요청된 페이지의 URL과 노드 정보가 일치하는지 확인하는 데 사용되는 HttpContext입니다.

반환

현재 요청된 페이지를 나타내는 SiteMapNode이거나, 그렇지 않고 SiteMapNode에서 일치하는 SiteMapNode를 찾을 수 없거나 페이지 컨텍스트가 null이면 null입니다.

설명

합니다 FindSiteMapNode 메서드는 추상 FindSiteMapNode 검색 하는 메서드를 SiteMapNode 현재 요청 된 페이지 기반 원시 URL 또는 요청의 가상 경로 대 한 개체입니다. 없음에 해당 하는 경우 SiteMapNodeSiteMap, null 반환 됩니다.

합니다 FindSiteMapNode 메서드를 확인 하지 않습니다 여부를 SiteMapNode 기본적으로 사용자에 게 액세스할 수 있습니다.

추가 정보

적용 대상