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


A

alexandis

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".
 
Ad

Advertisements

A

alexandis

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! :(
 
A

alexandis

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
 
A

alexandis

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.
 
A

alexandis

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...
 
Ad

Advertisements

A

alexandis

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.
 
Ad

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. After that, you can post your question and our members will help you out.

Ask a Question

Top