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

Why is the controller being repeatedly called?

3 Answers 65 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 04 Apr 2016, 04:16 PM

I set a break point in the constructor of my controller and I noticed that the controller is getting called several times on the startup of my project.

In my _Layout I have a menu control setup like:

 @(Html.Kendo().Menu()

            .Name("myMenu")
            .Animation(a =>
            {
                a.Open(o =>
                {
                    o.Expand(ExpandDirection.Vertical);
                    o.SlideIn(SlideDirection.Down);
                    o.Fade(FadeDirection.In);
                });
            })
            .HoverDelay(100)
            .Items(i =>
            {
                i.Add().Text("Job Profiles")
                    .Items(child =>
                    {
                        child.Add().Text("Item 1").Action("Act1", "Home");
                        child.Add().Text("Item 2").Action("Act2", "Home");
                        child.Add().Text("Item 3").Action("Act3", "Home");                        
                        child.Add().Text("Item 4").Action("Act4", "BadController");

                        child.Add().Text("Item 5").Action("BadAction", "Home");
                    });
            })
        )

 

 

So in my Home Controller I will see it being called 4 times.

Why does this happen?  It's not like it's validating the action/controller at this time, because Item 4 and Item 5 should blow up. (It will blow up, but only when the user clicks on the items).

This is causing poor performance due to initialization that I have occurring in the constructor.

 

Please advise.

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 06 Apr 2016, 12:33 PM

Hello Jim,

This may be related to the Menu security trimming, which is enabled by default. See the troubleshooting help topic for more information.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jim
Top achievements
Rank 1
answered on 06 Apr 2016, 02:12 PM

In general should the initialization be taken out of the constructor?

I can see by toggling the SecurityTrimming  the calls are reduced, but I would prefer not to disable it for fear that I'll forget to re-enable it on deployment.

0
Alex Gyoshev
Telerik team
answered on 08 Apr 2016, 07:37 AM

Hello Jim,

The multiple calls are only triggered in debug mode -- in production, the authorization is cached. You can conditionally toggle the security trimming only in production mode, but in that case, you will not observe its behavior on the site.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Menu
Asked by
Jim
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Jim
Top achievements
Rank 1
Share this question
or