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

SecurityTrimming in mvc core menu

3 Answers 117 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Ehsan
Top achievements
Rank 1
Ehsan asked on 05 Oct 2016, 11:33 AM

hi

im using asp.net mvc core app with telerik ui for mvc.

i need to use SecurityTrimming feature of menu for hiding unauthorized items...

<div class="nav navbar-nav">
               @(Html.Kendo()
                    
                   .Menu()
                       .Name("headerMenu")
                       .SecurityTrimming(s => s.HideParent(true))
                       .Items(items =>
                       {
                           items.Add().Text("Index").Action("Index", "Home");
                           items.Add().Text("About").Action("About", "Home");
                           items.Add().Text("Contact").Action("Contact", "Home");
                       }
                       )
               )
           </div>

but i get this error:

Severity    Code    Description    Project    File    Line    Suppression State
Error    CS1061    'MenuBuilder' does not contain a definition for 'SecurityTrimming' and no extension method 'SecurityTrimming' accepting a first argument of type 'MenuBuilder' could be found (are you missing a using directive or an assembly reference?)    mvccoreapp..NETCoreApp,Version=v1.0    C:\Users\Desktop\practice\01-sample-project-fa\src\mvccoreapp\Views\Shared\_Layout.cshtml    38    Active

it seems that .SecurityTrimming(s => s.HideParent(true)) does not implemented in this version. i tested it with  kendo.mvc.2016.2.630-preview and Telerik.UI.for.AspNet.Core 2016.3.914

plz help,tnx

3 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 07 Oct 2016, 08:20 AM

Hello Ehsan,

Due to changes in the ASP.NET Core framework and how the Authentication is implemented the MVC5 implementation of the SecurityTrimming option became obsolete. 

You can submit this as a feature request on UserVoice, so that it is considered for implementation in a future release.

Regards,
Ianko
Telerik by Progress
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 Feedback Portal and vote to affect the priority of the items
0
Ehsan
Top achievements
Rank 1
answered on 07 Oct 2016, 08:24 AM

hi

thanks,

is there any alternate solution?

0
Ianko
Telerik team
answered on 10 Oct 2016, 12:30 PM

Hello Ehsan,

Basically, you can have your own function in the view that returns a boolean value and checks the autentication for a certain URL/Action. Here is a sample for such a function: http://stackoverflow.com/a/19393116/6255278. This example works for MVC4 and 5. For Core you might need some further improvements.  

Next, use the function in the Visible() method of the items in order to show or hide them based on the  authentication results returned. 

Ianko
Telerik by Progress
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 Feedback Portal and vote to affect the priority of the items
Tags
Menu
Asked by
Ehsan
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Ehsan
Top achievements
Rank 1
Share this question
or