You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have multiple sites running from a single code base but using mostly the same URLs. There is a difference in the products that are displayed for each site and I am able to determine the correct set of products for the DynamicNodeProvider to display based on the host name (if it is supplied).
However, the host name is always null using the attribute below:
[MvcSiteMapNodeAttribute(Title = "Product", ParentKey = "Home", DynamicNodeProvider = "Model.Sitemap.ProductsDynamicNodeProvider, Model", Protocol = "*")]
The documentation says that the current request's host name is used if the protocol value is set but this doesn't seem to be the case.
The text was updated successfully, but these errors were encountered:
The default setup will automatically create a separate SiteMap instance per domain name (or subdomain). What you need to do in this case is to load the SiteMapCacheKey into a System.Uri instance and then use the Host property when retrieving your products.
This example assumes you have not provided a custom ISiteMapCacheKeyGenerator that changes the format of the SiteMapCacheKey string from a valid URI to another format.
Do note that the above code will throw an exception if a developer tries to use a non-URI as a SiteMapCacheKey when specifying the SiteMap instance to use for a HTML helper.
The host name will default to the current host name when resolving the URL, but this is based on the fact that the node configuration has a null or empty string for a host name.
As a side note, you led me to a bug in the default SiteMapCacheKeyGenerator. It should be favoring the "HTTP_HOST" header when present over the DnsSafeHost of the current request to derive the host name. This will ensure it will work consistently with the URL resolving behavior. This allows web farm and cloud environments a way to provide the host name to the application, since they will sometimes not be available in the request.
I have multiple sites running from a single code base but using mostly the same URLs. There is a difference in the products that are displayed for each site and I am able to determine the correct set of products for the DynamicNodeProvider to display based on the host name (if it is supplied).
However, the host name is always null using the attribute below:
[MvcSiteMapNodeAttribute(Title = "Product", ParentKey = "Home", DynamicNodeProvider = "Model.Sitemap.ProductsDynamicNodeProvider, Model", Protocol = "*")]
The documentation says that the current request's host name is used if the protocol value is set but this doesn't seem to be the case.
The text was updated successfully, but these errors were encountered: