Slow Nested RenderPartial Response Time

I have an asp.net view / page (dynamic) that is created from nested Html.RenderPartials. The view is sent to the appropriate viewmodel for rendering.

Firebug says the GET response for HTML is 9.89 s for 9.5 KB. To compare the frequently asked questions page (static html) of the same site, it is 1.3 s for 17K.

At first, I thought the end of SQL Entity was ending the slowdown due to the complexity of the viewmodel, but it seems he built a view model in less than 1 second according to my logs.

Any ideas why the MVC view takes so long to do, please, and how can I speed it up? I am considering partial loading via ajax.

(btw i am gzip and use cdn etc. - i killed the whole site to death)

Edit:

Added timers (stopwatch) for OnActionExecuting / OnActionExecuted and OnResultExecuting / OnResultExecuted.

12/09/2010 18:39:20: Controller: Profile Action: Index Elapsed time: 680.6431 - Action

12/09/2010 18:39:29: Controller: Profile Action: Index Elapsed time: 9202.063 - Result

9 seconds for the framework to display the view.

+3
source share
1 answer

Solution to the problem

Firstly, thank you all for your suggestions. I followed each sentence again and again until I found a problem. This is what was wrong, and perhaps someone can clarify to others.

VS2010 Performance Wizard , , PartialViews, , , , , .

foreach (ProfileComment item in Model)
{
    Html.RenderPartial("UserActivityComment", item);
}
...
Friends friend = Model.Friends.Where(e => e.ID == activity.ActionID).FirstOrDefault();
if (friend.FriendsProfile.UserName != Page.User.Identity.Name)
{
    Html.RenderPartial("UserActivityFriend.ascx", friend);
}

ProfileComment Friends ( ) ViewModel, . VM Entity Framework 0,3 . , VM.

, , . "for" , FirstOrDefault Performace.

, , . :

_entities.Friends.MergeOption = MergeOption.NoTracking;
_entities.ProfileComment.MergeOption = MergeOption.NoTracking;

, , .

Aia Research

blogs.microsoft.co.il/blogs/gilf/archive/2009/02/20/disabling-change-tracking-in-entity-framework.aspx

, . Btw !

+2

Source: https://habr.com/ru/post/1764376/


All Articles