Reputation: 46490
I am creating a CacheDependency on the file that my SiteMap provider uses. I would like to get the name of the file from my sitemap provider instead of hard coding it. Is there a way?
Duh, I forgot to mention: XmlSiteMapProvider that comes with ASP.NET
Reflector shows a private member field called _filename that isn't exposed in any way as far as I can tell.
Upvotes: 0
Views: 757
Reputation: 46490
I know it's dangerous but this worked:
public static string GetFilename(this XmlSiteMapProvider provider)
{
Type type = provider.GetType();
FieldInfo filenameField = type.GetField("_filename", BindingFlags.Instance | BindingFlags.NonPublic);
return (string)filenameField.GetValue(provider);
}
I think a safer way would be to just read the Web.Config file to get to the value.
Upvotes: 1