Developer forum

Forum » Development » AccessUserAddress call for every user you can impersonate causes slow login

AccessUserAddress call for every user you can impersonate causes slow login

Mikkel Hammer
Mikkel Hammer


We have a solution where when we log in as a person who can impersonate, there is a db call being made which is made for every user you can impersonate:

In this scenario, the logged in user can impersonate 7678 users.
Which results in a slow login because the call is being made for each user.

The list of users the person can impersonate is a query if that changes anything.

i've attached the debug=true result as a txt file, which you can change to .html if you want to have a look.

Is this call something that is necessary, and if not, something that can be toggled off?

Best regards,
Mikkel Hammer



Anders Ebdrup
Anders Ebdrup

It seems to be caused by a check like this:

if (Pageview.User.SecondaryUsers.Count > 0)

Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen

Sent to QA for verification.

Dynamicweb Employee
Stanislav Smetanin
This post has been marked as an answer

Hi Mikkel,
Do you probably use the Rapido templates?

In Rapido templates (..\Files\Templates\Designs\Rapido\MasterBlocks\ImpersonationBar.cshtml) we do next check to verify that User has secondary users (impersonation check):

    if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0)

Model.SecondaryUsers fills the collection of user models, so it could take a lot of time.

We can use Model.HasSecondaryUsers instead of it. It should work fast. So, instead of code above, we can do something like this

    if (Model.CurrentUser.ID > 0 && Model.HasSecondaryUsers )

I have added to this message the attachment with fixed ImpersonationBar.cshtml template for the case if you use the Rapido.

Kind regards.

Votes for this answer: 1
Mikkel Hammer
Mikkel Hammer

Hi Stanislav,

Yes it is indeed a rapido template, and HasSecondaryUsers seems to work as intended :)
Thanks a lot for the quick response!

Best regards,


You must be logged in to post in the forum