Miniprofiler is showing me that the slowest part of my page is the "Render" step (attached screenshot below).
What is occurring in that Render step? Is it the stage when your .aspx is converted into html to be sent to the client? Is there anywhere that I can add Miniprofiler.Current.Step()
to see exactly why it is slow?
The app is MVC4 on .NET4.5 with the .aspx render engine.
EDIT:
The controller action is just standard MVC stuff along the lines of:
public ActionResult Index()
{
ViewData["foo"] = GetFoo();
return View(model);
}
And the ASPX view is basic stuff like:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<p><% ViewData["foo"] %></p>
<% Html.RenderPartial("Something", Model) %>
</asp:Content>
First a ViewResult
Object is generated when you call the View()
Method.
This looks like
return View( Model );
Next the Render Step happens when the ExecuteResult()
method is called in a ViewResult
Object; Generating an HTML document that is sent to the client's browser.
The ExecuteResult() Method (Render) process involves:
ViewBag
.Partials
This last part, Rendering your Partials, is like a recursive version of the creating the ViewResult Object. A PartialView()
, RenderPartialView()
, or Action()
Method is executed creating a PartialViewResult Object. This new Result Object also has a ExecuteResult()
method which generates an HTML "sub-document" to merge with the "Parent" HTML Document.
Partial View rendering takes even longer if the Partial View has a child Action (Controller Method) associated with it because it carries the burden of instantiating another controller...
You use 2 partial Views; The time to render the partial views combines to 16.1 ms out of 37.1 ms (43% of total time).
Note about ASPX View Engine:
I would bet that the aspx engine takes longer to render views than the Razor engine. The aspx engine
In Conclusion:
Rendering Views (ExecuteResult()
) can be fairly time consuming compared with Route Engine resoluton (4.5 ms) and Controller instantiation (7.3 ms).
In your case, the time to render your partials and parent views seems high. But I haven't used mini-profiler to check myself.
It could be that your ASPX View Engine is THAT inefficient, or you may have Child Actions associated with your partials that are making heavy database calls...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With