views:

23

answers:

1

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?

Edit

Duh, I forgot to mention: XmlSiteMapProvider that comes with ASP.NET

Edit 2

Reflector shows a private member field called _filename that isn't exposed in any way as far as I can tell.

A: 

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.

Ronnie Overby