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

[Solved] NavigationItemAuthorization and custom AuthorizeAttribute

3 Answers 43 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
herman chan
Top achievements
Rank 1
herman chan asked on 03 Aug 2010, 06:33 PM
Hi,

We have a custom authorizeAttribute in our application such that if you are not login to our application, you'll get redirect to the login page.

It does it by returning false on AuthorizeCore when you are not login.  Moreover, we still want to user to be able to click on the menu item so that the user can get redirect correctly.  However, the NavigationItemAuthorization implementation will make the menu item invisible since AuthorizeCore returns false.  Is there anyway to turn of Authorization checks for certain menu items?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 05 Aug 2010, 10:29 AM
Hello herman chan,

The aforementioned behavior is expected. Menu items will be always check if they are authorized if the Action and Controller methods.

You can achieve your goal if you set URL of the menu items through URL() method like so:
items.Add().Text("Index2").Url(Url.Action("Index", "Home"));

Thus the items will always be visible and click-able.

Greetings,
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
0
herman chan
Top achievements
Rank 1
answered on 05 Aug 2010, 03:55 PM
Hi Georgi,

I am using the SiteMap binding method for menu item generation, so when I bind, can I use ItemAction to achieve what you mentioned?
0
Accepted
Georgi Krustev
Telerik team
answered on 05 Aug 2010, 04:02 PM
Hello herman chan,

That is correct. You can use ItemAction in order to set URL property of the item instead of Action and Controller properties.

Kind regards,
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
Menu
Asked by
herman chan
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
herman chan
Top achievements
Rank 1
Share this question
or