This is a migrated thread and some comments may be shown as answers.

Disabling checking Authorization in Menu.

1 Answer 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Juan Pablo Perez
Top achievements
Rank 1
Juan Pablo Perez asked on 04 Nov 2010, 04:43 PM
Hello,

Does anybody know if there is a way to disable checking Autorization in Items of Menu and PanelBar controls?. I've implemented a custome Authorize attribute based on database and a locatization routes (also based in database table) and the performance of the controls is very bad due to the stantard checking autorization.
 
Thanks in advance.

Juan Pablo

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 08 Nov 2010, 10:40 AM
Hello Juan Pablo Perez,

You can set the URL property of the Menu items instead of their ControllerName and ActionName properties. Thus the menu/panelBar UI component will not authorize the set URL.

The second options is to modify WriteItem extension method placed in Telerik.Web.Mvc.UI.NavigationItemContainerExtensions namespace like so:
public static void WriteItem<TComponent, TItem>(this TItem item, TComponent component, IHtmlNode parentTag, INavigationComponentHtmlBuilder<TItem> builder)
    where TItem : NavigationItem<TItem>, IContentContainer, INavigationItemContainer<TItem>
    where TComponent : ViewComponentBase, INavigationItemComponent<TItem>
{
    if (component.ItemAction != null)
    {
        component.ItemAction(item);
    }
 
    if (item.Visible)
    {
        var hasAccessibleChildren = item.Items.Any()
                                    && item.Items.IsAccessible(component.Authorization, component.ViewContext)
                                    && item.Items.Any(i => i.Visible);
 
        IHtmlNode itemTag = builder.ItemTag(item).AppendTo(parentTag);
 
        builder.ItemInnerContentTag(item, hasAccessibleChildren).AppendTo(itemTag);
 
        if (item.Template.HasValue() ||
            (item is IAsyncContentContainer ? !string.IsNullOrEmpty(((IAsyncContentContainer)item).ContentUrl) : false))
        {
            builder.ItemContentTag(item).AppendTo(itemTag);
        }
        else if (hasAccessibleChildren)
        {
            IHtmlNode ul = builder.ChildrenTag(item).AppendTo(itemTag);
 
            item.Items.Each(child => child.WriteItem(component, ul, builder));
        }
    }
}

All the best,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Juan Pablo Perez
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or