Fix ASP Issues
One of the most challenging tasks in web development is understanding the root cause of application performance issues. The effective approach to this task is monitoring the execution time of the main application components.
Dynamic Program Analysis (DPA) can be of great help in this process as it provides timing information for MVC actions, Razor page handlers, and Razor view components.
DPA supports ASP.NET Core in .NET 5.0 and later.
MVC action
In the Model-View-Controller (MVC) pattern, the controller is responsible for handling user input and coordinating model and view interactions. The controller is essentially a class that handles HTTP requests. The class methods responsible for handling the requests are called actions.
DPA lets you track the execution time of MVC actions, i.e., the time required by an action to process a request.
The default threshold is 500 ms.
Razor page handler
Razor Pages is a feature introduced in ASP.NET Core as an alternative to the MVC pattern for building web UI. It's a page-based programming model that makes building web UI more straightforward. In Razor Pages, handlers are methods within a page model that process HTTP requests.
DPA lets you track the execution time of handler methods, i.e., the time required by a particular method to process a request.
The default threshold is 500 ms.
Razor view component
Razor ViewComponents are a powerful feature in ASP.NET Core, designed to create reusable components that encapsulate rendering logic and data fetching. These components can be invoked from Razor views and are ideal for creating dynamic content sections like menus, widgets, forms, etc.
The entry point to a view component is a Invoke
or InvokeAsync
method. This method is responsible for executing any necessary logic and returning the view that should be rendered. When you add a view component to a Razor view, the view component's Invoke
or InvokeAsync
method is called.
DPA lets you track the execution time of view components, i.e., the time required by a particular Invoke
method to perform all the underlying logic.
The default threshold is 300 ms.
How to fix
There could be several reasons why an action/page handler/Invoke
method takes too long to execute. The most common ones are: the method performs too many calculations, database queries, or HTTP requests. Communication issues might also be a reason.
The general advice is to analyze the method code and try to exclude the reasons listed above one by one.