Add a sitemap provider at runtime in asp.net (MVC framework)
-
05-07-2019 - |
Question
I'm building a regionalized site each region has it own sitemap and own content. The regions can be added at runtime. Is there any way to add a sitemap provider at runtime?
I need multiple site map providers at once so that I can leverage the mvcsitemap without to many changes.
Solution
You can create your custom site map provider in order to take information from database or from another file than web.sitemap.
Example of database sitemap: http://msdn.microsoft.com/en-us/magazine/cc163657.aspx
OTHER TIPS
There is an MVC sitemap provider available at: http://mvcsitemap.codeplex.com/
I'm using it for a project right now. It has caching functionality built into the code so your overhead shouldn't be too bad. Even in debug mode running the sitemap for every request takes < 100 ms so I wouldn't worry about performance.
Your performance concerns are a little yagni too. "Could be quite resource consuming". You don't know so your just prematurely optimizing.