What I am about to suggest amounts to what some (myself included) would call a hack... I'm sure there has to be a better way, but I haven't really played with the built-in navigation stuff. Here it goes..
My solution has three site map files. One for default where the details page is not included "default", a second where the details page is a child of products "FromProducts" and a third where the details page is a child of search "FromSearch".
A little bit of configuration information needs to be added to the web.config file to take this approach.
<siteMap defaultProvider="Default">
<providers>
<add
name="Default"
type="System.Web.XmlSiteMapProvider"
siteMapFile="~/Web.sitemap" />
<add
name="FromProduct"
type="System.Web.XmlSiteMapProvider"
siteMapFile="~/FromProduct.sitemap" />
<add
name="FromSearch"
type="System.Web.XmlSiteMapProvider"
siteMapFile="~/FromSearch.sitemap" />
</providers>
</siteMap>
And now the code to make it happen on the details page. For brevities sake, I'm using this code inline, ideally you'd put it in a method.
protected void Page_Init(object sender, EventArgs e)
{
string Referrer = (Request.UrlReferrer == null) ? null : Request.UrlReferrer.AbsolutePath.ToLower();
if (string.IsNullOrEmpty(Referrer) == true)
{
Response.Redirect("~/Default.aspx");
}
else if (Referrer.EndsWith("products.aspx") == true)
{
SiteMapPath1.SiteMapProvider = "FromProduct";
}
else if (Referrer.EndsWith("search.aspx") == true)
{
SiteMapPath1.SiteMapProvider = "FromSearch";
}
}That's it...
You are correct, this solution is less than ideal, but it was my first stab at a solution. I'll hack around at dynamically adding details to the SiteMapPath and post again if I have any luck.