Constructor calls from Menu?

2 posts, 0 answers
  1. Caecilia
    Caecilia avatar
    5 posts
    Member since:
    Feb 2014

    Posted 12 Mar 2018 Link to this post

    Hi,I have something like this in my _LayoutStandard.html for an ASP.NET MVC5 site:

    @(Html.Kendo().Menu().Name("tdtMenu").Items(lvl1 =>
    {
      lvl1.Add()
          .ImageUrl(Url.Content("~/Content/Images/tools.png"))
          .Items(lvl2 =>
          {
              lvl2.Add().Text("Server info").Action("About", "Foo");
              lvl2.Add().Text("Change my password").Action("Manage", "Account");
              lvl2.Add().Text("Administration").Action("Index", "Admin");
              lvl2.Add().Text("Testpages").Items(lvl3 =>
              {
                  lvl3.Add().Text("Testpage - Fitting").Action("FittingTest", "Fitting");
                  lvl3.Add().Text("Testpage - SignalR").Action("Index", "Foo");
                  lvl3.Add().Text("Testpage - Obsolete").Action("Project", "Overview");
              });
              lvl2.Add().Text("Projects").Action("Overview", "Project");
          });
    }).Events(e => e.Select("TDT.MenuSelect")))

     

    I have noticed, that the Action() calls lead to calling the controller constructors. Why is that? Isn't that a performance issue?

    Thank you for more information on this!

  2. Caecilia
    Caecilia avatar
    5 posts
    Member since:
    Feb 2014

    Posted 13 Mar 2018 in reply to Caecilia Link to this post

    Turns out, it's the default active security trimming feature of the the Kendo menu, which leads to calling each controller constructor to determine whether the user is authorized to access the menu item. Turning this off with .SecurityTrimming(false) to not have the behaviour. Cheers!
Back to Top