Aspect-oriented programming(AOP) is based on Object-oriented programming(OOP) concepts to extend concepts. It separates the main code to record the log messages, fix error messages or other messages recorded in files or other server space, and let the source code coupling level reduce in the project. These log messages can include performance information, event logs, transformation messages, etc. This best example is the filter of the ASP.NET MVC.
It has more third party tools can provide to do, such as PostSharp and Unity. Now, I use Microsoft.Extensions.Logging package to implement AOP in ASP.NET Core project is based on the Onion architecture(Building MVC pattern project by Visual Studio 2017 ( ASP.Net Core Part )).
In the AOP of the web application project, I will focus on the action filter of the ASP.NET Core and the action filter of the ASP.NET MVC. The action filter default order of execution is from sequence 1 to sequence 6.
| Sequence | Filter scope | Filter method |
|---|---|---|
| 1 | Global | OnActionExecuting |
| 2 | Controller or Razor page | OnActionExecuting |
| 3 | Method | OnActionExecuting |
| 4 | Method | OnActionExecuted |
| 5 | Controller or Razor page | OnActionExecuted |
| 6 | Global | OnActionExecuted |
Microsoft.Extensions.Logging tutorial
Step 1. Create the Logging folder under the web application project. Right-click on the web project -> Add -> New folder.
Step 2. Create the two folders under the Logging folder. One folder name is “Interface.” Another folder name is “Repository.”
What is the API gateway? An API gateway is an API management tool that sits…
The .NET 5 SDK is a kind of milestone in the .NET world. The .NET…
In object-oriented design, the dependency inversion principle is a specific methodology for loosely coupling software…
In the field of software engineering, the interface segregation principle (ISP) states that no code…
Subtype Requirement: Let be a property provable about objects of type T. Then should be true for objects of type S where S is…
In object-oriented programming, the open–closed principle states "software entities (classes, modules, functions, etc.) should be…
View Comments