This question is locked. New answers and comments are not allowed.
I have a scenario that I want to populate different sitemap base on the user's culture setting.
i've tried 3 ways,
One is dynamically translate the sitemap node's title to the user's language, but in this method, I have to go through the sitemap nodes to achieve the translating job, and if the nodes level goes deep, this becomes terrible, at least not elegant.
The other way I tried is, create different sitemap files for each supporting language, and populate the right sitemap base on the user culture setting dynamically, this sounds ideal, but unfortunately, the parameter set in the populatesitemapattribute must be a value parameter and I can not pass the culture setting to it something like
it will hit compiler error. means you have to explicitely give things like SiteMapName="mysitemap", ViewDataKey="Eng"
As can not pass the 'sitemapname' and 'viewdatakey' to the populatesitemapattribute dynamically(it's my supposed, maybe have another way can realize), I tried the 3rd way, I tried to combine all language sitemaps into one sitemap which is the default web.sitemap, and inside there I just create another level node to take the language setting at the title, and while i do populatesitemap, actually I'm using override populatesitemapattribute which give me a chance to finetune the sitemapnodes, and in there i just base on the sitemapnode's title whether equals the user's culture setting and populate the right nodes sitemap, but this process goes silly, at least i think so. The best things is I can dynamically choose the desired sitemap I registered in the sitemapdictionary as I like, either inside the populatesitemapattribute class or just pass the parameter to the SiteMapName and ViewDataKey parameter while assign the populatesitemapattribute to controllers. The later one I think is more elegant and simple.
Does anybody have same scenario? Could you share your solutions on this?
Actually just on the go suffering this, I'm trying to use sitemapmanager to choose the sitemap, but from the help document, I can not figure out how to select the sitemap, and I've tried use SiteMapManager.SiteMaps.TryGetvalue method, but failed to finish it, does anybody know how?
Appreciated your reply!