This question is locked. New answers and comments are not allowed.
Some thoughts added to the thread started by "Shawn" on Feb 25, 2010.
I remember reading in another thread that the sitemap is aggressively cached, in a multi-language environment this could have some negative impact if the global cache is used: the sitemap will be cached for every visitor regardless of the language setting of their browser.
Consider the following scenario;
1) the site uses a default language, lets assume "en-US"
2) there are multiple sitemap files, one per language and the URLs are defined in a way that the overflow parameter of the route (ie. the {id} parameter) changes according to the selected language like this:
en-US sitemap
de-DE sitemap
3) when the visitor hits a page, the controller retrieves the language exposed by the browser, lets assume "de-DE", and selects the sitemap accordingly.
The result will be:
1) the displayed menu is still using "en-US"
2) the routes are internally built using "en-U" thus the overflow parameters are still English words.
This could lead to some interesting results if the site dynamically retrieves the page content either from a database or from another repository based on the UI culture of the current thread.
Adjusting the "<siteMap cacheDurationInMinutes="10">" as suggested by Kazi Manzur Rashid won't change anything, because the sitemap is apparently cached at the site level and not at the session level.
I tried to map different ViewData keys to different sitemaps based on the language, but it looks like that the sitemap manager only uses the key "SiteMap" to retrieve and load the content of the sitemap file. Running a small project based on these assumptions always returns the following error:
"An item with the same key has already been added. "
The controller looks like this:
and the action looks like this:
Am I missing something?
I remember reading in another thread that the sitemap is aggressively cached, in a multi-language environment this could have some negative impact if the global cache is used: the sitemap will be cached for every visitor regardless of the language setting of their browser.
Consider the following scenario;
1) the site uses a default language, lets assume "en-US"
2) there are multiple sitemap files, one per language and the URLs are defined in a way that the overflow parameter of the route (ie. the {id} parameter) changes according to the selected language like this:
en-US sitemap
| <siteMapNode title="Root"> |
| <siteMapNode controller="Home" action="Index/One" title="One" /> |
| <siteMapNode controller="Home" action="Index/Two" title="Two" /> |
| </siteMapNode> |
de-DE sitemap
| <siteMapNode title="Wurzel"> |
| <siteMapNode controller="Home" action="Index/Eins" title="Eins" /> |
| <siteMapNode controller="Home" action="Index/Zwei" title="Zwei" /> |
| </siteMapNode> |
3) when the visitor hits a page, the controller retrieves the language exposed by the browser, lets assume "de-DE", and selects the sitemap accordingly.
The result will be:
1) the displayed menu is still using "en-US"
2) the routes are internally built using "en-U" thus the overflow parameters are still English words.
This could lead to some interesting results if the site dynamically retrieves the page content either from a database or from another repository based on the UI culture of the current thread.
Adjusting the "<siteMap cacheDurationInMinutes="10">" as suggested by Kazi Manzur Rashid won't change anything, because the sitemap is apparently cached at the site level and not at the session level.
I tried to map different ViewData keys to different sitemaps based on the language, but it looks like that the sitemap manager only uses the key "SiteMap" to retrieve and load the content of the sitemap file. Running a small project based on these assumptions always returns the following error:
"An item with the same key has already been added. "
The controller looks like this:
| [AutoPopulateSourceCode] |
| [PopulateSiteMap(SiteMapName = "sample", ViewDataKey = "sample")] |
| public class HomeController : Controller |
and the action looks like this:
| [PopulateSiteMap(SiteMapName = "sample", ViewDataKey = "sample")] |
| [SourceCodeFile("Sitemap", "~/Web1031.sitemap")] |
| [SourceCodeFile("Sitemap", "~/Web1033.sitemap")] |
| public ActionResult Index() |
| { |
| if (!SiteMapManager.SiteMaps.ContainsKey("sample")) |
| { |
| SiteMapManager.SiteMaps.Register<XmlSiteMap>("sample", sitmap => |
| sitmap.LoadFrom(string.Format("~/Web{0}.sitemap", |
| Thread.CurrentThread.CurrentUICulture.LCID))); |
| } |
| return View(); |
| } |
Am I missing something?