Correlate.AspNet.WebApi
6.1.1
dotnet add package Correlate.AspNet.WebApi --version 6.1.1
NuGet\Install-Package Correlate.AspNet.WebApi -Version 6.1.1
<PackageReference Include="Correlate.AspNet.WebApi" Version="6.1.1" />
<PackageVersion Include="Correlate.AspNet.WebApi" Version="6.1.1" />
<PackageReference Include="Correlate.AspNet.WebApi" />
paket add Correlate.AspNet.WebApi --version 6.1.1
#r "nuget: Correlate.AspNet.WebApi, 6.1.1"
#:package Correlate.AspNet.WebApi@6.1.1
#addin nuget:?package=Correlate.AspNet.WebApi&version=6.1.1
#tool nuget:?package=Correlate.AspNet.WebApi&version=6.1.1
Classic ASP.NET (IIS) integration.
An ASP.NET (classic/.net framework) implementation to correlate activities between decoupled components (eg. microservices) via a HTTP header.
Usage
This package provides a managed IIS HTTP module to automatically handle the correlation of HTTP requests and responses. To activate the module, add it to your web.config file.
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="CorrelateHttpModule" type="Correlate.AspNet.CorrelateHttpModule, Correlate.AspNet.WebApi, Version=6.1.0.0, Culture=neutral, PublicKeyToken=null" />
</modules>
</system.webServer>
You need to specify a fully qualified name for
CorrelateHttpModule.
If you already have a <modules>/<httpModules> section in your web.config, you can simply just add the line with CorrelateHttpModule.
Dependencies
The HTTP module requires certain dependencies to be registered and resolvable from the GlobalConfiguration.Configuration.DependencyResolver dependency container.
For convenience, this package comes with an adapter DefaultDependencyResolver that is based on IServiceProvider (Microsoft's current abstraction). With this adapter, you can use the dependency injection registration extensions provided by the Correlate.DependencyInjection package to configure the DependencyResolver on HttpConfiguration.
Of course, dependency registration can be done using any DI container of your choice, as long as it supplies all the necessary services.
Example
Global.asax.cs
using System.Web.Http;
namespace MyWebApp;
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
GlobalConfiguration.Configure(DependencyInjectionConfig.Register);
}
}
~/App_Start/DependencyInjectionConfig.cs
using System.Web.Http;
using Correlate.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
namespace MyWebApp;
public static class DependencyInjectionConfig
{
public static void Register(HttpConfiguration config)
{
ServiceProvider services = new ServiceCollection()
// Register dependencies.
.AddCorrelate()
.BuildServiceProvider();
// Create and set the adapter.
config.DependencyResolver = new DefaultDependencyResolver(services);
}
}
Note: do not dispose the created
ServiceProviderwhen leaving this method. It will be disposed automatically by the adapter on app recycle/shutdown.
Useful links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Correlate.DependencyInjection (>= 6.1.1)
- Microsoft.AspNet.WebApi (>= 5.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes are at https://github.com/skwasjer/Correlate/releases