SecurityTrimming in mvc core menu

4 posts, 0 answers
  1. Ehsan
    Ehsan avatar
    10 posts
    Member since:
    Nov 2014

    Posted 05 Oct Link to this post

    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

  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 07 Oct Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Ehsan
    Ehsan avatar
    10 posts
    Member since:
    Nov 2014

    Posted 07 Oct in reply to Ianko Link to this post

    hi

    thanks,

    is there any alternate solution?

  5. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 10 Oct Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready