SiteMapProvider.FindSiteMapNode 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
파생 클래스에서 재정의되는 경우 페이지를 나타내는 개체를 검색 SiteMapNode 합니다.
오버로드
| Name | Description |
|---|---|
| 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
를 검색할 페이지를 식별하는 URL입니다 SiteMapNode.
반품
식별된 SiteMapNode페이지를 나타내는 A rawURL 입니다. 그렇지 않으면 null해당 SiteMapNode 페이지를 찾을 수 없거나 보안 트리밍을 사용하도록 설정하여 SiteMapNode 현재 사용자에 대해 반환할 수 없는 경우입니다.
예제
다음 코드 예제에서는 추상 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 애플리케이션 상대 구문을 올바르게 구문 분석하고 처리하는지 확인합니다.
ASP.NET 기본 사이트 맵 공급자인 XmlSiteMapProvider 클래스는 SiteMapNode 개체의 URL을 클래스가 유지 관리하는 다양한 컬렉션의 키로 사용합니다. 따라서 URL을 SiteMapNode 제공하는 경우 사이트 맵 공급자의 범위 내에서 고유해야 합니다. URL이 제공되지 않으면 고유 식별자가 생성되어 해당 URL을 식별 SiteMapNode합니다.
구현자 참고
파생 클래스에서 메서드를 재정의 FindSiteMapNode(String) 할 때 현재 사이트 맵에서 공급자가 URL과 일치하는 개체를 찾을 수 없으며 공급자가 자식 공급자를 지원하는 경우 SiteMapNode 검색을 자식 공급자로 확장해야 합니다.
추가 정보
적용 대상
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
HttpContext 노드 정보를 요청된 페이지의 URL과 일치시킬 때 사용됩니다.
반품
현재 요청된 페이지를 나타내는 A SiteMapNode 이고, null그렇지 않으면 페이지 컨텍스트에서 SiteMapNode 해당 SiteMapNode 페이지를 찾을 수 없거나 페이지 컨텍스트가 있는 경우입니다null.
설명
메서드는 FindSiteMapNode 추상 FindSiteMapNode 메서드를 호출하여 요청의 원시 URL 또는 가상 경로를 기반으로 현재 요청된 페이지에 대한 개체를 검색 SiteMapNode 합니다. 에 해당하는 SiteMapNode 항목이 SiteMapnull 없으면 반환됩니다.
이 메서드는 FindSiteMapNode 기본적으로 사용자가 액세스할 수 있는지 여부를 SiteMapNode 확인하지 않습니다.