XmlSiteMapProvider.BuildSiteMap メソッド
定義
XML ファイルからサイト マップ情報を読み込み、メモリ内で構築します。Loads the site map information from an XML file and builds it in memory.
public:
override System::Web::SiteMapNode ^ BuildSiteMap();
public override System.Web.SiteMapNode BuildSiteMap ();
override this.BuildSiteMap : unit -> System.Web.SiteMapNode
Public Overrides Function BuildSiteMap () As SiteMapNode
戻り値
サイト マップ ナビゲーション構造のルート SiteMapNode を返します。Returns the root SiteMapNode of the site map navigation structure.
例外
XmlSiteMapProvider が正常に初期化されませんでした。The XmlSiteMapProvider was not initialized properly.
- または --or-
一意でない siteMapFile
について <siteMapNode>
が解析されます。A siteMapFile
is parsed for a <siteMapNode>
that is not unique.
- または --or-
siteMapFile
で指定されているファイル名拡張子が .sitemap ではありません。The file specified by the siteMapFile
does not have the file name extension .sitemap.
- または --or-
siteMapFile
で指定されているファイルが存在しません。The file specified by the siteMapFile
does not exist.
または-or-
provider
の <siteMapNode>
で構成されているプロバイダーがルート ノードとして null を返します。A provider configured in the provider
of a <siteMapNode>
returns a null root node.
siteMapFile
は指定されていますが、パスがアプリケーションの現在のディレクトリ構造内にありません。The siteMapFile
is specified but the path lies outside the current directory structure for the application.
構成ファイルの読み込み中にエラーが発生しました。There is an error loading the configuration file.
または-or-
構成ファイルの最上位の要素が named <siteMap>
ではありません。The top element of the configuration file is not named <siteMap>
.
- または --or- 構成ファイルに複数の最上位ノードがあります。More than one top node exists in the configuration file.
- または --or-
<siteMap>
の子の名前が <siteMapNode>
ではありません。A child of the <siteMap>
has a name other than <siteMapNode>
.
- または --or-
<siteMapNode>
について予期しない属性が解析されます。An unexpected attribute is parsed for the <siteMapNode>
.
または-or-
<siteMapNode>
が設定されている provider
の下位にサブ要素が入れ子になっています。Sub-elements are nested beneath a <siteMapNode>
where the provider
is set.
- または --or-
roles
の <siteMapNode>
に有効でない文字が含まれています。The roles
of the <siteMapNode>
contain characters that are not valid.
- または --or-
一意でない url
について <siteMapNode>
が解析されます。A url
is parsed for a <siteMapNode>
that is not unique.
- または --or- SiteMapNode で、重複した Key の値が検出されました。A SiteMapNode was encountered with a duplicate value for Key.
- または --or-
ResourceKey の Title または SiteMapNode が指定されていたか、ノードに定義された custom
属性に明示的なリソース式が格納されていました。The ResourceKey or Title was specified on a SiteMapNode or a custom
attribute defined for the node contained an explicit resource expression.
または-or-
明示的なリソース式が、Title の Description または SiteMapNode、または custom
属性に適用されていましたが、明示的な情報が有効ではありませんでした。An explicit resource expression was applied either to the Title or Description or to a custom
attribute of a SiteMapNode but the explicit information was not valid.
または-or- Url の SiteMapNode の解析中にエラーが発生しました。An error occurred while parsing the Url of a SiteMapNode.
指定されたプロバイダーが、現在のサイト マップ プロバイダーのコレクションに存在しません。A named provider cannot be found in the current site map providers collection.
サイト マップ ファイルを参照する <siteMapNode>
の siteMapFile
が空の文字列です。A <siteMapNode>
referencing a site map file contains an empty string for the siteMapFile
.
siteMapFile
の <siteMapNode>
で物理パスが使用されています。A siteMapFile
of a <siteMapNode>
uses a physical path.
- または --or-
siteMapFile
で指定されたファイルへの仮想パスの解析試行中にエラーが発生しました。An error occurred while attempting to parse the virtual path to the file specified in the siteMapFile
.
例
次のコード例は、 XmlSiteMapProviderクラスの新しいインスタンスを作成して初期化し、XML データからサイトマップを構築する方法を示しています。The following code example demonstrates how to create a new instance of the XmlSiteMapProvider class and initialize it to build a site map from XML data.
<%@ Page Language="c#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
// Create an instance of the XmlSiteMapProvider class.
XmlSiteMapProvider testXmlProvider = new XmlSiteMapProvider();
NameValueCollection providerAttributes = new NameValueCollection(1);
providerAttributes.Add("siteMapFile","test.sitemap");
// Initialize the provider with a provider name and file name.
testXmlProvider.Initialize("testProvider", providerAttributes);
// The BuildSiteMap method is implicitly called when the
// RootNode property is accessed.
// Prints "/myvirtualdirectory/WebForm1.aspx"
Response.Write(testXmlProvider.RootNode.Url + "<BR>");
// Prints "/myvirtualdirectory/WebForm2.aspx"
Response.Write(testXmlProvider.CurrentNode.Url + "<BR>");
}
上記のコード例では、ASP.NET アプリケーションの仮想ルートにある XML ファイルを使用します。The preceding code example uses an XML file that is located in the virtual root of the ASP.NET application. ファイルの形式は次のとおりです。The file has the following format:
<siteMap>
<siteMapNode title="RootNode" description="The root page." url="WebForm1.aspx">
<siteMapNode title="CurrentNode" description="Some sub page." url="WebForm2.aspx"/>
</siteMapNode>
</siteMap>
注釈
メソッドBuildSiteMapは、永続ストレージからサイトマップを読み込んでビルドするために呼び出されます。The BuildSiteMap method is called to load and build the site map from persistent storage.
セキュリティトリミングが有効になっている場合の既定の動作についIsAccessibleToUserては、「」の「解説」を参照してください。For the default behavior when security trimming is enabled, see "Remarks" in IsAccessibleToUser.
オブジェクトがXmlSiteMapProviderサイトマップデータを解析して読み込むと、 SiteMapNode読み込まれSiteMapNodeCollectionたすべてのオブジェクトとコレクションが読み取り専用になります。After the XmlSiteMapProvider object parses and loads site map data, all loaded SiteMapNode objects and SiteMapNodeCollection collections are made read-only. がXmlSiteMapProviderサイトマップファイルUrlからプロパティを解析すると、アプリケーション相対 url と相対 url がアプリケーションの絶対仮想パスに変換されます。When the XmlSiteMapProvider parses the Url property from a site map file, it converts application-relative URLs, as well as relative URLs, to application-absolute virtual paths.
はXmlSiteMapProvider 、web.sitemap ファイルのファイル変更通知をサブスクライブします。The XmlSiteMapProvider subscribes to file change notifications for the .sitemap file. Web.sitemap ファイルXmlSiteMapProviderに変更が加えられると、が再度読み込まれ、サイトマップ構造が再構築されます。If any change is made to the .sitemap file, the XmlSiteMapProvider is reloaded, and the site map structure is rebuilt.