Home Update How to make use of correlation IDs in ASP.NET Core MVC

How to make use of correlation IDs in ASP.NET Core MVC

402
How to use correlation IDs in ASP.NET Core MVC


Suppose you’ve gotten applied an software based mostly on a microservices structure. In a microservices-based software, you’ll sometimes have a conglomeration of a number of providers. One of the numerous advantages of microservices structure is that every service is constructed, deployed, and maintained independently, selling excessive scalability.

But let’s say one thing goes fallacious. How would you determine, by wanting on the logs, the place the request failed? Your log recordsdata may embody tons of of hundreds or maybe hundreds of thousands of log messages. Hence looking out via the log entries could be a frightening activity. This is the place correlation IDs come to the rescue.

In a earlier article right here, I talked in regards to the fundamentals of correlation IDs and how one can work with them in ASP.NET Web API. In this text we’ll study how we are able to work with correlation IDs in ASP.NET Core.

To work with the code examples offered on this article, it’s best to have Visual Studio 2019 put in in your system. If you don’t have already got a duplicate, you possibly can obtain Visual Studio 2019 right here.

Create an ASP.NET Core MVC undertaking in Visual Studio 2019

First off, let’s create an ASP.NET Core undertaking in Visual Studio 2019. Following these steps will create a brand new ASP.NET Core MVC 5 undertaking in Visual Studio 2019.

  1. Launch the Visual Studio IDE.
  2. Click on “Create new project.”
  3. In the “Create new project” window, choose “ASP.NET Core Web App (Model-View-Controller)” from the checklist of templates displayed.
  4. Click Next.
  5. In the “Configure your new project” window, specify the identify and site for the brand new undertaking.
  6. Optionally test the “Place solution and project in the same directory” test field, relying in your preferences.
  7. Click Next.
  8. In the “Additional Information” window proven subsequent, choose .NET 5.zero because the goal framework from the drop-down checklist on the prime. Leave the “Authentication Type” as “None” (default).
  9. Ensure that the test containers “Enable Docker,” “Configure for HTTPS,” and “Enable Razor runtime compilation” are unchecked as we received’t be utilizing any of these options right here.
  10. Click Create.

Next create a brand new controller on this undertaking — let or not it’s named ValuesController (that’s the default identify). We’ll use this ASP.NET Core MVC undertaking and controller to work with correlation IDs within the subsequent sections of this text.

What are correlation IDs? Why are they helpful?

Correlation IDs are distinctive identifiers that allow you to correlate…



Source hyperlink

LEAVE A REPLY

Please enter your comment!
Please enter your name here