Logo

Maarten Balliauw {blog}

ASP.NET, ASP.NET MVC, Azure, PHP, OpenXML, VSTS, ...

About the author

Maarten Balliauw is an MVP ASP.NET and is currently employed as .NET Software Engineer at RealDolmen. His interests are mainly web applications developed in ASP.NET (C#) or PHP.
More about me More about me
Send mail E-mail me


Microsoft Most Valuable Professional - MVP - ASP.NET

Subscribe to my RSS feed Follow me on Twitter! View Maarten Balliauw's profile on LinkedIn RealDolmen - Rock-solid passion for ICT
I'm a speaker at TechDays Belgium and TechDays Finland

Search

Latest Twitter

    Follow me on Twitter...

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

    © Copyright Maarten Balliauw 2010

    New CodePlex project: MvcSiteMap – ASP.NET MVC sitemap provider

    NavigationIf you have been using the ASP.NET MVC framework, you possibly have been searching for something like the classic ASP.NET sitemap. After you've played with it, you even found it useful! But not really flexible and easy to map to routes and controllers. To tackle that, last year, somewhere in August, I released a proof-of-concept sitemap provider for the ASP.NET MVC framework on my blog.

    The blog post on sitemap provider I released back then has received numerous comments, suggestions, code snippets, … Together with Patrice Calve, we’ve released a new version of the sitemap provider on CodePlex: MvcSiteMap.

    This time I’ll not dive into implementation details, but provide you with some of the features our sitemap provider erm… provides.

    First things first: registering the provider

    After downloading (and compiling) MvcSiteMap, you will have to add a reference to the assembly in your project. Also, you will have to register the provider in your Web.config file. Add the following code somewhere in the <system.web> section:

    <siteMap defaultProvider="MvcSiteMap">
        <providers>
            <add name="MvcSiteMap"
                 type="MvcSiteMap.Core.MvcSiteMapProvider" 
                 siteMapFile="~/Web.Sitemap"
                 securityTrimmingEnabled="true"
                 cacheDuration="10"/>
        </providers>
    </siteMap>

    We’ve just told ASP.NET to use the MvcSiteMap sitemap provider, read sitemap nodes from the Web.sitemap file, use secrity trimming and cache the nodes for 10 minutes.

    Defining sitemap nodes

    Defining sitemap nodes is quite easy: add a Web.sitemap file to your project and popukate it with some nodes. Here’s an example:

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap>
      <mvcSiteMapNode title="Home" controller="Home" action="Index" isDynamic="true" dynamicParameters="*">
        <mvcSiteMapNode title="About Us" controller="Home" action="About" />

        <mvcSiteMapNode title="Products" controller="Products">
          <mvcSiteMapNode title="Will be replaced in controller"
                          controller="Products" action="List"
                          isDynamic="true" dynamicParameters="id"
                          key="ProductsListCategory"/>
        </mvcSiteMapNode>
        <mvcSiteMapNode title="Account" controller="Account">
          <mvcSiteMapNode title="Login" controller="Account" action="LogOn" />
          <mvcSiteMapNode title="Account Creation" controller="Account" action="Register" />
          <mvcSiteMapNode title="Change Password" controller="Account" action="ChangePassword" />
          <mvcSiteMapNode title="Logout" controller="Account" action="LogOff" />
        </mvcSiteMapNode>
      </mvcSiteMapNode>
    </siteMap>

    Too much info? Let’s break it down. The sitemap consists of several nodes, defined by using a <mvcSiteMapNode> element. Each node can contain other nodes, as you can see in the above example. A node should also define some attributes: title and controller. Title is used by all sitemap controls of ASP.NET, controller is used to determine the controller to link to. Here’s a list of possible attributes:

    Attribute Required? Description
    title Yes Title of the node.
    controller Yes Controller the node should link to.
    action Optional Action method of the specified controller the node should link to.
    key Optional A key used to identify the node. Can be specified but is generated by the MvcSiteMap sitemap provider when left blank.
    isDynamic Optional Specifies if this is a dynamic node (explained later)
    dynamicParameters When isDynamic is set to true. Specifies which parameters are dynamic. Multiple can be specified using a comma (,) as separator.
    visibility Optional When visibility is set to InSiteMapPathOnly, the node will not be rendered in the menu.
    * Optional Any other parameter will be considered to be an action method parameter.

    Regarding the wildcard (*), here’s a sample sitemap node:

    <mvcSiteMapNode title="Contact Maarten" controller="About" action="Contact" who=”Maarten” />

    This node will map to the URL http://…./About/Contact/Maarten.

    Using the sitemap

    We can, for example, add breadcrumbs to our master page. Here’s how:

    <asp:SiteMapPath ID="SiteMapPath" runat="server"></asp:SiteMapPath>

    Looks exactly like ASP.NET Webforms, no?

    Dynamic parameters

    You got to click it, before you kick it. In the table mentioned above, you may have seen the isDynamic and dynamicParameters attributes. This may sound a bit fuzzy, but it’s actually quite a powerful feature. Consider the following sitemap node:

    <mvcSiteMapNode title="Product details" controller="Product" action="Details" isDynamic=”true” dynamicParameters=”id” />

    This node will actually be used by the sitemap controls when any URL refering /Products/Details/… is called:

    • http://…./Products/Details/1234
    • http://…./Products/Details/5678
    • http://…./Products/Details/9012

    No need for separate sitemap nodes for each of the above URLs! One node is enough to provide your users with a consistent breadcrumb showing their location in your web application.

    The MvcSiteMapNode attribute

    Who said sitemaps should always be completely defined in XML? Why not use the MvcSiteMapNode attribute we created:

    [MvcSiteMapNode(ParentKey="ProductsListCategory", Title="Product details", IsDynamic=true, DynamicParameters="id")]
    public ActionResult Details(string id)
    {
        // ...
    }

    We are simply telling the MvcSiteMap sitemap provider to add a child node to the node with key “ProductsListCategory” which should have the title “Product details”. Controller and action are simply determined by the sitemap provider, based on the action method this attribute is declared on. Dynamic parameters also work here, by the way.

    Do you have an example?

    Yes! Simply navigate to the MvcSiteMap project page on CodePlex and grab the latest source code. The sitemap provider is included as well as an example website demonstrating all features.

    kick it on DotNetKicks.com


    Categories: ASP.NET | C# | CodePlex | General | ICT | Internet | MVC | Projects

    Comments

    Microsoft RealDolmen blogs | Reply

    Tuesday, March 24, 2009 10:32 AM

    trackback

    Trackback from Microsoft RealDolmen blogs

    New CodePlex project: MvcSiteMap

    Kam United States | Reply

    Tuesday, March 24, 2009 5:15 PM

    Kam

    I like it. I'm currently working on a similar project from the other direction: I want to make the actual URLs look like the sitemap does, so I'm working with the routing engine to support hierarchical routes to a controller based on a database driven hierarchy.

    Backlinking the routes is the biggest problem with it (e.g. it breaks Html.ActionLink()) but I hope to come up with a decent solution for that.

    Michael D. Hall United States | Reply

    Wednesday, March 25, 2009 8:23 AM

    Michael D. Hall

    Very cool, I had played around with your previous posting on the concept but wasn't ready to implement it. But now you saved me the trouble! Awesome, thank you!

    Matthew Canada | Reply

    Wednesday, March 25, 2009 11:57 AM

    Matthew

    I tried using this with the code for the www.asp.net tutorial on Providing Website Navigation with SiteMaps (C#)  @ http://www.asp.net/learn/mvc/tutorial-20-cs.aspx. I keep getting exceptions on the line

    var topLevelNodes = SiteMap.RootNode.ChildNodes;

    as the ChildNodes is empty/null

    maartenba Belgium | Reply

    Wednesday, March 25, 2009 12:45 PM

    maartenba

    I'll check if I can add a custom MenuHelper on our implementation. Keep an eye on the CodePlex sources!

    maartenba Belgium | Reply

    Wednesday, March 25, 2009 2:14 PM

    maartenba

    There you go... Check the latest source code download.

    Matthew Canada | Reply

    Wednesday, March 25, 2009 3:15 PM

    Matthew

    Nice menu.  Quick response!!!  
    Thanks.

    DotNetShoutout | Reply

    Friday, March 27, 2009 11:39 PM

    trackback

    Trackback from DotNetShoutout

    New CodePlex project: MvcSiteMap - ASP.NET MVC sitemap provider - Maarten Balliauw

    Alberto Ferreira Portugal | Reply

    Tuesday, March 31, 2009 5:51 PM

    Alberto Ferreira

    Could we use Security Trimming? How?

    Request:
    - Could choose some Nodes to "not visible", so that "Menu" don't render them (because I could want to have them in my Breadcrumb and not in my Menu - don't want a Details menu item).

    Matt Penner United States | Reply

    Wednesday, April 01, 2009 2:45 AM

    Matt Penner

    I don't want to be a downer but can someone explain to me the benefit of site maps?  Web Forms was never my thing and now I'm loving MVC but I don't see the point of a site map.  Since the site map file isn't publicly available it's not for SEO.  The only examples I ever find are menus and tree layouts.  If I have dynamic menus based on login, roles and context I don't think I can use a standard control that consumes a site map.

    So, again, if someone can tell me (or better yet, show me) where they have used this in a decent sized site in a practical fashion I'd love to learn more.

    maartenba Belgium | Reply

    Wednesday, April 01, 2009 8:13 AM

    maartenba

    Yes, you can. It will recognize all [Authorize] attributes in controllers and base its list of nodes on that.

    maartenba Belgium | Reply

    Wednesday, April 01, 2009 8:14 AM

    maartenba

    Benefit: you have one location where the structure of your site is defined for use in breadcrumbs and menus. If you want, you can also use it to generate a sitemap.xml for Google, a static sitemap page showing all nodes, ...

    Alberto Ferreira Portugal | Reply

    Thursday, April 02, 2009 1:36 PM

    Alberto Ferreira

    Hi Maarten,

    Security Trimming isn't working... I have some Authorize attributes, but this nodes still showing up on your Menu Helper.

    Thanks

    maartenba Belgium | Reply

    Thursday, April 02, 2009 1:39 PM

    maartenba

    Will check that. Keep an eye on CodePlex source code.

    Alberto Ferreira Portugal | Reply

    Thursday, April 02, 2009 5:00 PM

    Alberto Ferreira

    Dear Maarten,

    Incredible how fast are you Smile

    It works. Thank You a lot!

    I will try to take advantage of your good will, and request you the following features:

    - At your Helper Menu, a property to specify the starting node level (ex.: for a 2º level left menu);
    - At SiteMapNode an attribute that specify if it will be visible, so that Menu Helper don't show this nodes (like I asked you before, sometimes we want that a Action Method just shows in BreadCrumb but not at Menu);
    - Generate your URL's like URL.Action() do. Sometimes, we have custom routes that don't map "directely" Controller and Action methods. For example, I have a controller "ProductsController" and a action method "CreateByFile", but my route is: "Products/Add/ByFile". If I ask URL.Action("CreateByFile", "Products") it will give me "Products/Add/ByFile". Your SiteMapProvider gives me "Products/CreateByFile" ...

    Thank you again.

    maartenba Belgium | Reply

    Thursday, April 02, 2009 5:02 PM

    maartenba

    Can you add those requests on CodePlex? (http://mvcsitemap.codeplex.com/WorkItem/List.aspx)

    Will see what I can do.

    Michael Russia | Reply

    Monday, April 20, 2009 3:56 PM

    Michael

    Hi!
    This code on the real project works very slowly
                        if (this.scanAssembliesForSiteMapNodes)
                        {
                            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                            {
                                ProcessNodesInAssembly(assembly);
                            }
                        }

    maartenba Belgium | Reply

    Monday, April 20, 2009 3:58 PM

    maartenba

    You can disable that when not needed. (check the example on CodePlex' Web.config file)

    Michael Sommer Netherlands | Reply

    Wednesday, April 22, 2009 10:20 AM

    Michael Sommer

    Hi,

    I tried it out, and loving it, but for some reason my nodes which I add by defining '[MvcSiteMapNode( ParentKey = "FeedbackKey", Title = "Details", DynamicParameters = "id", IsDynamic = true )]' in the class is only showing the breadcrumb for only the first details page I request. Every other details page with the same path, but different id is not showing the breadcrumb. Any ideas what I do wrong?

    maartenba Belgium | Reply

    Wednesday, April 22, 2009 1:14 PM

    maartenba

    Have you tried the latest CodePlex sources (mvcsitemap.codeplex.com)? The example in there does the same and does work as expected.

    Michael Sommer Netherlands | Reply

    Wednesday, April 22, 2009 3:10 PM

    Michael Sommer

    Yep, tried it allready, but to no effect. Appearantly the currentnode is null on the details pages.
    By the way it does not work on any of the details pages now. :-(

    maartenba Belgium | Reply

    Wednesday, April 22, 2009 3:14 PM

    maartenba

    Can you post a bug on CodePlex site for this? Preferably with a small reproducing example.

    Martin Uruguay | Reply

    Thursday, April 23, 2009 11:23 PM

    Martin

    If i want to make a 2 level menu. I need to use the sitemap helper? the menu helper works only for one level menu's ?
    Thanks.
    Great work!.

    maartenba Belgium | Reply

    Friday, April 24, 2009 7:34 AM

    maartenba

    Can you give an example of how that would look? You can also post this as a feature request on http://mvcsitemap.codeplex.com

    charlie Canada | Reply

    Monday, April 27, 2009 5:27 PM

    charlie

    I wish it can support following pattern if that is possible:

    In the web.config try to define provider follow this pattern:
       And in the web.config:
            
          <siteMap defaultProvider="default">
          <providers>
             <add name="MvcSiteMapDefault"
                 type="MvcSiteMap.Core.MvcSiteMapProvider"
                 SiteMapFile="~/Web.Sitemap"
                 securityTrimmingEnabled="true"
                 cacheDuration="10"
                 scanAssembliesForSiteMapNodes="true"
                 treatAttributesAsRouteValues="true"
                 aclModule="MvcSiteMap.Core.DefaultMvcSiteMapAclModule, MvcSiteMap.Core"/>
        </providers>
            <add name="MvcSiteMapAdmin"
                 type="MvcSiteMap.Core.MvcSiteMapProvider"
                 SiteMapFile="~/Web.Sitemap"
                 securityTrimmingEnabled="true"
                 cacheDuration="10"
                 scanAssembliesForSiteMapNodes="true"
                 treatAttributesAsRouteValues="true"
                 aclModule="MvcSiteMap.Core.DefaultMvcSiteMapAclModule, MvcSiteMap.Core"/>
        </providers>
        </siteMap>  

    And in the code behind of maste page, call following in page_load::
    private void SetSitemap()
            {
                if (Roles.IsUserInRole("Administrator"))
                {
                    DemoSiteMapDataSource.SiteMapProvider = "Admin";
                }
                else if (Roles.IsUserInRole("Branch Administrator"))
                {
                    DemoSiteMapDataSource.SiteMapProvider = "BranchAdmin";
                }
                else if (Roles.IsUserInRole("User"))
                {
                    DemoSiteMapDataSource.SiteMapProvider = "user";
                }
            }

    And DemoSiteMapDataSource is type of following defined in maste page:

    <asp:SiteMapDataSource ID="DemoSiteMapDataSource" runat="server" />      

    And that require the MenuHelper class use SiteMapDataSource type as input.
        

    Maarten Balliauw Belgium | Reply

    Monday, April 27, 2009 7:02 PM

    Maarten Balliauw

    Will fix that. I've created a work item for it: mvcsitemap.codeplex.com/.../View.aspx

    Jamir United States | Reply

    Tuesday, April 28, 2009 6:41 AM

    Jamir

    Great work Maarten!

    In my MVC project, I am trying to convert to MvcSitemap from SiteMap. I have different sub folders within my Controller projects, which holds the controllers. RouteRegister registers and redirects appropriately depending on the folder and subfolder.

    In my current implementation using SiteMap. I have following syntax
          <siteMapNode  title="Mileage Rates"  url="~/Setup/MileageRates" description="Mileage Rates" roles="*" />

    I would like to pass /SetUp/MileageRates/Index and not just MileageRates/Index. How do I do it using MVCSitemap? When I tried giving controller="Setup/MileageRates" action="Index", it fails in MvcSiteMapProvider.cs, does not recognize "Setup/MileageRates" as a controller, which is expected.

    Any suggestion?

    Thanks,
    Jamir

    maartenba Belgium | Reply

    Tuesday, April 28, 2009 11:54 AM

    maartenba

    @Jamir, simply pass in the controller name (SetUp or MileageRates I assume). MvcSiteMap will use routing to determine the correct URL here.

    Jamir United States | Reply

    Wednesday, April 29, 2009 5:09 AM

    Jamir

    maartenba,

    I have used MVC areas as subfolders under views as well as controller see blog below. More specifically I am using Sharp-Architecture.

    devlicio.us/.../...cal-subfolders-under-views.aspx

    Sharp-Architecture:
    http://code.google.com/p/sharp-architecture/

    For my project, http://localhost:1383/MileageRates will not work, I have to specify http://localhost:1383/Setup/MileageRates instead.

    Do you see any workaround here?

    Thank you very much for your time.
    Jamir

    maartenba Belgium | Reply

    Wednesday, April 29, 2009 8:57 AM

    maartenba

    What does your route table look like and what is the controller name you are trying to reach?

    maartenba Belgium | Reply

    Wednesday, April 29, 2009 3:47 PM

    maartenba

    Just had a look at S# architecture -> specify your sitemap node with
    <mvcSiteMapNode ... area="Setup" controller="...." action="...."/>

    Jamir United States | Reply

    Thursday, April 30, 2009 6:33 AM

    Jamir

    maartenba,

    Couple of question on how to include Authorization to menu.

    1. I have implemented my own FormAuthentication, how can I pass Roles after user logged into the system such that my [Authorize(Roles = "Superuser")]  will Authorize based on user Role. After user is logged into the system, I need to some how set this Roles for the user, what is the handle.

    2. Once I have #1 working, I would like to make my menus to be invisible when user does not have particular Role for the Action that is being displayed. When the user is not logged on, menus with Role [*] can only show up all other menus to disappear.

    Thank you very much for your time and help.
    Jamir

    maartenba Belgium | Reply

    Thursday, April 30, 2009 7:30 AM

    maartenba

    You can simply enable security trimming for the site map and it will automatically take [Authorize] attributes into account.

    Jamir United States | Reply

    Sunday, May 03, 2009 8:28 PM

    Jamir

    Hi Marteen,

    I had some issue with my Authorization, I have fixed that. Now I can push my roles to MVC Context. I have source from "10098" dated April 24th.

    My Web.Config has securityTrimmingEnabled="true" entry and my Controller method has [Authorize(Roles = "Superuser")]

    Now when my user does not have the "SuperUser" role. It just shows my login screen. It does not change any behavior by removing or adding securityTrimmingEnabled="true" in Web.Config... I am missing any additional flag to set ?

    I have a second question. I have secondary menus. My primary menu should not do any work by clicking it. Similar to using SiteMapNode with BLANK URL. When I don't have any Controller or action in the definition, it assumes the higher nodes definitions, which is Home in this case and errors out with duplicate URL. Is it possible to do achieve such functionality ?

    Thank you very much for your time and help.
    Jamir

    maartenba Belgium | Reply

    Monday, May 04, 2009 9:24 AM

    maartenba

    Jamir, that is all normal behaviour for ASP.NET (MVC)?

    Second question: you can use regular stemap nodes for that (<siteMapNode url="...">)

    Jamir United States | Reply

    Monday, May 04, 2009 4:51 PM

    Jamir

    Maarthen,

    One the first question. I am guessing now using MVCSiteMap I cannot hide the menus which use does not have access. Is that correct?

    What is the purpose of "securityTrimmingEnabled" ?

    Thanks again.
    Jamir

    Maarten Balliauw Belgium | Reply

    Monday, May 04, 2009 5:06 PM

    Maarten Balliauw

    Security trimming should in fact hide menu items when user is not authorized. If this is not working, can you post an issue on http://mvcsitemap.codeplex.com?

    Jamir United States | Reply

    Tuesday, May 05, 2009 5:52 AM

    Jamir

    Maarten,

    I have added an issue into the http://mvcsitemap.codeplex.com. Please let me know, if I can provide any further information.

    Thanks,
    Jamir

    maartenba Belgium | Reply

    Tuesday, May 05, 2009 7:54 AM

    maartenba

    Will look into it. Thanks!

    Neil Kilbride Ireland | Reply

    Tuesday, May 12, 2009 2:24 PM

    Neil Kilbride

    Great work with the MVC sitemap provider - can't seem to get localilsation working when I set enableLocalization="true" as described @ msdn.microsoft.com/en-us/library/ms178427.aspx - is this a known issue/limitation?

    maartenba Belgium | Reply

    Tuesday, May 12, 2009 3:41 PM

    maartenba

    Can you post a small sample app + issue on http://mvcsitemap.codeplex.com?

    kamilH Poland | Reply

    Sunday, May 31, 2009 11:14 PM

    kamilH

    Hi
    you shoud add
      if (!string.IsNullOrEmpty(attributes["resourceKey"]))
                    ResourceKey = attributes["resourceKey"];
    to public override void Initialize(string name, NameValueCollection attributes) in Provider

    maartenba Belgium | Reply

    Tuesday, June 02, 2009 9:03 AM

    maartenba

    Thanks for the tip!

    Germán Uruguay | Reply

    Wednesday, June 10, 2009 7:30 PM

    Germán

    Hi, Maarten, nice job! However, i´m still not able to use localization as it is stated in msdn. I enabled localization in the sitemap file, added resourcekeys in every sitemap node and also created the resource file Web.sitemap.resx file in my App_GlobalResources folder. Am i doing something wrong? Can you post working example with localization enabled??
    Regards,
    Germán

    maartenba Belgium | Reply

    Thursday, June 11, 2009 8:28 AM

    maartenba

    Working on that... You'll know when it's done Smile

    Elijah Manor United States | Reply

    Wednesday, June 17, 2009 9:14 PM

    Elijah Manor

    I am working on slowly integrating MVC into an existing WebForm project.

    I was wondering if there would be a way to use your SiteMapProvider to support both controllers/actions and/or url paths?

    I was hoping to reuse the same solution across both mvc & webform.

    maartenba Belgium | Reply

    Thursday, June 18, 2009 4:40 PM

    maartenba

    Working on it, work item can be followed: mvcsitemap.codeplex.com/.../View.aspx

    Jules United Kingdom | Reply

    Saturday, June 27, 2009 1:09 PM

    Jules

    Hi Maarten,

    Good work on the MVC sitemap controller. Will functionality be added to store the sitemap in a SQL table?

    Also, can the sitemap provider be used with the asp.net menu control on a master page (I need a dynamic hierarchical menu)?

    Regards

    Jules

    maartenba Netherlands | Reply

    Monday, June 29, 2009 9:40 AM

    maartenba

    Menu control should be working.

    Eric United States | Reply

    Wednesday, July 01, 2009 11:38 PM

    Eric


    Maarten, have you had any issues when the cache expires?

    Once our expires, if we return to the main page, all the sitemap nodes now only point to
    the main page. This effectively locks us on the main page.

    it reproduces when the timeout is set to 1 min, so i know it's not cookie expiriation or security thing, it's the
    sitemap Cache time.

    any hints or hlpe is appreicated.

    Thanks,

    E-

    maartenba Belgium | Reply

    Thursday, July 02, 2009 8:06 AM

    maartenba

    Can you post this as an issue on http://mvcsitemap.codeplex.com?
    Please include any steps to reproduce this behaviour.

    Ronnie Overby United States | Reply

    Thursday, July 02, 2009 12:31 AM

    Ronnie Overby

    I know that you can pass an arbitrary route parameter to a MvcSiteMapNode by just adding an xml attribute in Web.Sitemap. I need to do this from an action method. How do you do it?

    Specifically, I need to do something like this:
    ((MvcSiteMapNode)SiteMap.CurrentNode.ParentNode).AddRouteParameter("id", product.Category.ID);

    I'm betting that there is a real way to do this, but I just am missing it.

    Thanks.

    maartenba Belgium | Reply

    Thursday, July 02, 2009 8:05 AM

    maartenba

    Can you post this as a feature request on http://mvcsitemap.codeplex.com?

    answerspluto.com | Reply

    Tuesday, July 14, 2009 3:49 AM

    pingback

    Pingback from answerspluto.com

    list of urls - 5 « Answers Pluto

    thomas United States | Reply

    Tuesday, July 28, 2009 12:23 AM

    thomas

    hey maarten, this MVC Sitemap provider is fantastic, thank you!

    fyi, I downloaded build 23592; it seems to still have a bug where setting SiteTitle is lost. I patched this (temporarily, hopefully) by adding an override to the Title property in your MvcSiteMapNode class.
    I'll check back for updates. Many thanks again.

    maartenba Belgium | Reply

    Tuesday, July 28, 2009 8:08 AM

    maartenba

    Can you send me that patch?

    Andy McShane United Kingdom | Reply

    Tuesday, July 28, 2009 10:13 AM

    Andy McShane

    |Hi Maarten, great piece of work, thanks. Now I have all of my translated text for my site in external xml files that I load into a data dioctionary at runtime, where would be the best place for me to make a small change to your code to be able replace the text in the sitemap node with my translated text? Remeber I am not using resource files here.

    Maarten Belgium | Reply

    Tuesday, July 28, 2009 10:17 AM

    Maarten

    That would be the MvcSiteMapNode's Title property (you can add/replace this)

    Andy McShane United Kingdom | Reply

    Tuesday, July 28, 2009 11:42 AM

    Andy McShane

    Excellent, thanks.

    Jonas Sweden | Reply

    Saturday, August 01, 2009 12:51 PM

    Jonas

    Repeating Alberto's request for a feature "At your Helper Menu, a property to specify the starting node level (ex.: for a 2º level left menu)"

    This would be a really good feature since many menus are designed in that fashion. So if you could find the time to add that feature it would be awesome Smile

    maartenba Belgium | Reply

    Friday, August 07, 2009 10:00 AM

    maartenba

    It's there Smile Download the latest bits if you want to use them.

    Jonas Sweden | Reply

    Sunday, August 23, 2009 7:39 PM

    Jonas

    Where? How? I downloaded 24982 but I can't see how to find this feature.

    Thanks

    latho Norway | Reply

    Tuesday, August 11, 2009 4:18 PM

    latho

    Hi.

    This is great stuff. And I love the way it allows to combine menus as indicated in the last comment!
    keep up the good work!!

    I am currently trying to render breadcrumbs for more "unstructured" data. I have a LOT of categories (>5000) and the depth of nodes varies greatly (from 1 to 19). Do you have any good ways of rendering/mapping stuff like that?

    For the business logic to work I really just need to pick up the last category id since all ids are unique (illustrated in the urls-below).
    So /Category/1/11/111 shall result in the same content as putting in /Category/111 except I want to render breadcrumbs as the navigation-path and not by tracking parents recursively.

    my tree is similar to this:

    cat 1                             - url: /Category/1
      cat 1.1                        - url: /Category/11
        cat 1.1.1                   - url: /Category/111
        cat 1.1.2
    cat 2
      cat 2.1
      cat 2.2
        cat 2.2.1
          cat 2.2.1.2
      cat 2.3

    awattar Poland | Reply

    Monday, August 24, 2009 1:43 PM

    awattar

    Is there any possibility to display "Home" node when we are on Home Controller, now there is an empty space.

    Phunk Norway | Reply

    Tuesday, September 22, 2009 2:57 PM

    Phunk

    Hi Maarten,

    How can I render all elements in the Web.sitemap, please? I would like the whole menu tree rendered for a drop down menu:

    <ul id="menu">
      <li>Account
          <ul>
                <li>Create user</li>
                <li>Manage roles</li>
          </ul>
      </li>
      <li>Home</li>
      <li>Away</li>
    </ul>

    I've of course set up the Web.sitemap with the same hierarchy, but I can't find a way to render it correctly in the Masterpage.

    Thanks!

    maartenba Belgium | Reply

    Tuesday, September 22, 2009 5:31 PM

    maartenba

    Check the HtmlHelper.Sitemap() method.

    Mikael Östberg Sweden | Reply

    Friday, September 25, 2009 3:36 PM

    Mikael Östberg

    Hello!

    I'm having a Controller with a default action that takes a complex object as parameter and when that Action is invoked, SiteMap.CurrentNode is null, which breaks the HtmlHelper.Menu method.

    The signature of my method is: public ActionResult Index([ModelBinder(typeof (UserQueryModelBinder))] UserQuery userQuery)

    I'm trying to match this by having this in the Web.sitemap file:
    <mvcSiteMapNode title="Search" controller="Search" action="Index" isDynamic="true" dynamicParameters="*" />

    Could it be that the problem is the complex object parameter of my method?

    Any ideas..?

    Thanks!




    maartenba Belgium | Reply

    Saturday, September 26, 2009 6:29 PM

    maartenba

    Hello Mikael, are you using the latest version from CodePlex? If yes, can you post an issue on the issue tracker over there? (mvcsitemap.codeplex.com)

    Microsoft RealDolmen blogs | Reply

    Wednesday, October 28, 2009 3:07 PM

    trackback

    ASP.NET MVC MvcSiteMapProvider 1.0 released

    ASP.NET MVC MvcSiteMapProvider 1.0 released

    Add comment




      Country flag

    biuquote
    • Comment
    • Preview
    Loading