How to invoke XMLSiteMapProvider in login page (logged_in method)?

Discussion in 'ASP .Net' started by alexandis, Feb 2, 2008.

  1. alexandis

    alexandis Guest

    I use additional custom attributes in sitemapnodes of my web.sitemap,
    besides - it contains startUrl to navigate to when leaving login page,
    depending on role.

    <siteMapNode startUrl="Clients/clientlist.aspx" title="Clients"
    roles="admin,partner" startFor="admin,partner">

    All in all - i need to invoke my custom xmlsitemap provider in
    logged_in event of login control to access my custom methods and
    properties. But i have no idea how to do this! I create my provider
    instance in logged_in event (i suspect i shouldn't do this directly)
    and when I try to call its custom method - i'm getting:

    "XmlSiteMapProvider is not initialized. Call Initialize() method
    first".
     
    alexandis, Feb 2, 2008
    #1
    1. Advertisements

  2. alexandis

    alexandis Guest

    Ok, i tried something like this:
    WizardsSiteMapProvider wizardsSiteMapProvider = new
    WizardsSiteMapProvider();
    NameValueCollection providerAttributes = new NameValueCollection();
    providerAttributes.Add("siteMapFile", "Web.sitemap");
    providerAttributes.Add("securityTrimmingEnabled", "true");
    wizardsSiteMapProvider.Initialize("AdminSiteMapProvider",
    providerAttributes);

    - but base.RootNode.ChildNodes return 0 elements for some reason! :(
     
    alexandis, Feb 2, 2008
    #2
    1. Advertisements

  3. alexandis

    alexandis Guest

    BuildSiteMap() follows Initialize method - just calling
    base.BuildSiteMap().

    Then I call my custom method, where I check base.RootNode.ChildNodes.
    And it shows zero, although it should be filled from web.sitemap :(

    Changing to providerAttributes.Add("siteMapFile", "~/Web.sitemap")
    didn't help
     
    alexandis, Feb 3, 2008
    #3
  4. alexandis

    alexandis Guest

    Hi, myself,

    you should not assign securitytrimmingenabled section and then you
    will see all the child nodes.
    Also please be aware, that at login page isAuthenticated is false,
    etc. Take this into account when doing role checks inside your custom
    method.
     
    alexandis, Feb 3, 2008
    #4
  5. alexandis

    alexandis Guest

    Moving further... Ok, now i'm inside, redirected to correct page. And
    need to make there a 'program click' on asp:menu item. Hmm, how to do
    this...
     
    alexandis, Feb 3, 2008
    #5
  6. alexandis

    alexandis Guest

    Well... instead of additional 'click' i may just make a check in
    master page_load:
    if (!isPostBack) {
    // highlight menu item, knowing its Url
    // MenuItem menuItem = FindMenuItemByUrl(menuobj, Url);
    // menuItem.Selected = true;
    }
    But my custom recursive FindMenuItemByUrl as yet doesn't work
    properly: it does return correct item, but some parent folders are not
    opened, although i use expand method... Strange.
     
    alexandis, Feb 3, 2008
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.