SiteMap.Providers Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a read-only collection of named SiteMapProvider objects that are available to the SiteMap class.
public:
static property System::Web::SiteMapProviderCollection ^ Providers { System::Web::SiteMapProviderCollection ^ get(); };
public static System.Web.SiteMapProviderCollection Providers { get; }
static member Providers : System.Web.SiteMapProviderCollection
Public Shared ReadOnly Property Providers As SiteMapProviderCollection
A SiteMapProviderCollection of named SiteMapProvider objects.
The site map feature is not enabled.
The default provider specified in the configuration does not exist.
The feature is supported only when running in Low trust or higher.
The following code example demonstrates how to retrieve the Providers collection from the SiteMap class, and then iterate through it.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
// Navigate the SiteMap built by the default SiteMapProvider.
Response.Write(SiteMap.RootNode.ToString() + "<BR>");
Response.Write(SiteMap.RootNode.Url + "<BR>");
Response.Write(SiteMap.RootNode.Title + "<BR>");
foreach (SiteMapNode sitemapnode in SiteMap.RootNode.ChildNodes)
{
// Iterate through the ChildNodes SiteMapNodesCollection
// maintained by the RootNode.
Response.Write(sitemapnode.Url + "<BR>" );
}
IEnumerator providers = SiteMap.Providers.GetEnumerator();
while (providers.MoveNext())
{
Response.Write(providers.Current);
Response.Write(" ");
Response.Write("<BR>");
}
}
</SCRIPT>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<SCRIPT runat="server">
Private Sub Page_Load(Sender As Object, E As EventArgs)
' Navigate the SiteMap built by the default SiteMapProvider.
Response.Write(SiteMap.RootNode.ToString() & "<BR>")
Response.Write(SiteMap.RootNode.Url & "<BR>")
Response.Write(SiteMap.RootNode.Title & "<BR>")
Dim sitemapnode As SiteMapNode
For Each sitemapnode In SiteMap.RootNode.ChildNodes
' Iterate through the ChildNodes SiteMapNodesCollection
' maintained by the RootNode.
Response.Write(sitemapnode.Url & "<BR>" )
Next
Dim providers As IDictionaryEnumerator = SiteMap.Providers.GetEnumerator()
While (providers.MoveNext())
Response.Write(providers.Current)
Response.Write(" ")
Response.Write("<BR>")
End While
End Sub ' Page_Load
</SCRIPT>
If you have more than just the default provider configured for your site, you will see each provider displayed. For example, if you are using the sample Microsoft Access provider (see StaticSiteMapProvider), you see the following output:
XmlSiteMapProvider System.Web.XmlSiteMapProvider
AccessSiteMapProvider Samples.AspNet.AccessSiteMapProvider
The site map providers that are listed in the Providers collection are those that are specified in the configuration hierarchy to initialize the SiteMap class. Only the default provider (identified by the Provider property) is guaranteed to be used by the SiteMap during initialization; the presence of a provider in the Providers collection means that it was specified in the configuration and was available during initialization.
Applies to
제품 | 버전 |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET 피드백
.NET은(는) 오픈 소스 프로젝트입니다. 다음 링크를 선택하여 피드백을 제공해 주세요.