Microsoft.Extensions.Http An options class for configuring the default . Gets a list of operations used to configure an . Gets a list of operations used to configure an . Gets or sets the length of time that a instance can be reused. Each named client can have its own configured handler lifetime value. The default value of this property is two minutes. Set the lifetime to to disable handler expiry. The default implementation of will pool the instances created by the factory to reduce resource consumption. This setting configures the amount of time a handler can be pooled before it is scheduled for removal from the pool and disposal. Pooling of handlers is desirable as each handler typically manages its own underlying HTTP connections; creating more handlers than necessary can result in connection delays. Some handlers also keep connections open indefinitely which can prevent the handler from reacting to DNS changes. The value of should be chosen with an understanding of the application's requirement to respond to changes in the network environment. Expiry of a handler will not immediately dispose the handler. An expired handler is placed in a separate pool which is processed at intervals to dispose handlers only when they become unreachable. Using long-lived instances will prevent the underlying from being disposed until all references are garbage-collected. The which determines whether to redact the HTTP header value before logging. Gets or sets a value that determines whether the will create a dependency injection scope when building an . If false (default), a scope will be created, otherwise a scope will not be created. This option is provided for compatibility with existing applications. It is recommended to use the default setting for new applications. The will (by default) create a dependency injection scope each time it creates an . The created scope has the same lifetime as the message handler, and will be disposed when the message handler is disposed. When operations that are part of are executed they will be provided with the scoped via . This includes retrieving a message handler from dependency injection, such as one registered using . A builder abstraction for configuring instances. The is registered in the service collection as a transient service. Callers should retrieve a new instance for each to be created. Implementors should expect each instance to be used a single time. Gets or sets the name of the being created. The is set by the infrastructure and is public for unit testing purposes only. Setting the outside of testing scenarios may have unpredictable results. Gets or sets the primary . Gets a list of additional instances used to configure an pipeline. Gets an which can be used to resolve services from the dependency injection container. This property is sensitive to the value of . If true this property will be a reference to the application's root service provider. If false (default) this will be a reference to a scoped service provider that has the same lifetime as the handler being created. Creates an . An built from the and . Constructs an instance of by chaining one after another with in the end of the chain. The resulting pipeline is used by infrastructure to create instances with customized message handlers. The resulting pipeline can also be accessed by using instead of . An instance of to operate at the bottom of the handler chain and actually handle the HTTP transport operations. An ordered list of instances to be invoked as part of sending an and receiving an . The handlers are invoked in a top-down fashion. That is, the first entry is invoked first for an outbound request message but last for an inbound response message. The HTTP message handler chain. or is . contains a entry. -or- The DelegatingHandler.InnerHandler property must be . DelegatingHandler instances provided to HttpMessageHandlerBuilder must not be reused or cached. Used by the to apply additional initialization to the configure the immediately before is called. Applies additional initialization to the A delegate which will run the next . The configured . A factory abstraction for a component that can create typed client instances with custom configuration for a given logical name. The type of typed client to create. The is infrastructure that supports the and functionality. This type should rarely be used directly in application code, use instead to retrieve typed clients. A default can be registered in an by calling . The default will be registered in the service collection as a singleton open-generic service. The default uses type activation to create typed client instances. Typed client types are not retrieved directly from the . See for details. This sample shows the basic pattern for defining a typed client class. class ExampleClient { private readonly HttpClient _httpClient; private readonly ILogger _logger; // typed clients can use constructor injection to access additional services public ExampleClient(HttpClient httpClient, ILogger<ExampleClient> logger) { _httpClient = httpClient; _logger = logger; } // typed clients can expose the HttpClient for application code to call directly public HttpClient HttpClient => _httpClient; // typed clients can also define methods that abstract usage of the HttpClient public async Task SendHelloRequest() { var response = await _httpClient.GetAsync("/helloworld"); response.EnsureSuccessStatusCode(); } } This sample shows how to consume a typed client from an ASP.NET Core middleware. // in Startup.cs public void Configure(IApplicationBuilder app, ExampleClient exampleClient) { app.Run(async (context) => { var response = await _exampleClient.GetAsync("/helloworld"); await context.Response.WriteAsync("Remote server said: "); await response.Content.CopyToAsync(context.Response.Body); }); } This sample shows how to consume a typed client from an ASP.NET Core MVC Controller. // in Controllers/HomeController.cs public class HomeController : ControllerBase(IApplicationBuilder app, ExampleClient exampleClient) { private readonly ExampleClient _exampleClient; public HomeController(ExampleClient exampleClient) { _exampleClient = exampleClient; } public async Task<IActionResult> Index() { var response = await _exampleClient.GetAsync("/helloworld"); var text = await response.Content.ReadAsStringAsync(); return Content("Remote server said: " + text, "text/plain"); }; } Creates a typed client given an associated . An created by the for the named client associated with . An instance of . Handles logging of the lifecycle for an HTTP request. Initializes a new instance of the class with a specified logger. The to log to. is . Initializes a new instance of the class with a specified logger and options. The to log to. The used to configure the instance. or is . Loggs the request to and response from the sent . Handles logging of the lifecycle for an HTTP request within a log scope. Initializes a new instance of the class with a specified logger. The to log to. is . Initializes a new instance of the class with a specified logger and options. The to log to. The used to configure the instance. or is . Loggs the request to and response from the sent . Extension methods for configuring an Adds a delegate that will be used to configure a named . The . A delegate that is used to configure an . An that can be used to configure the client. Adds a delegate that will be used to configure a named . The . A delegate that is used to configure an . An that can be used to configure the client. The provided to will be the same application's root service provider instance. Adds a delegate that will be used to create an additional message handler for a named . The . A delegate that is used to create a . An that can be used to configure the client. The delegate should return a new instance of the message handler each time it is invoked. Adds a delegate that will be used to create an additional message handler for a named . The . A delegate that is used to create a . /// An that can be used to configure the client. The delegate should return a new instance of the message handler each time it is invoked. The argument provided to will be a reference to a scoped service provider that shares the lifetime of the handler being constructed. Adds an additional message handler from the dependency injection container for a named . The . An that can be used to configure the client. The type of the . The handler type must be registered as a transient service. The will be resolved from a scoped service provider that shares the lifetime of the handler being constructed. Adds a delegate that will be used to configure the primary for a named . The . A delegate that is used to create an . An that can be used to configure the client. The delegate should return a new instance of the message handler each time it is invoked. Adds a delegate that will be used to configure the primary for a named . The . A delegate that is used to create an . An that can be used to configure the client. The delegate should return a new instance of the message handler each time it is invoked. The argument provided to will be a reference to a scoped service provider that shares the lifetime of the handler being constructed. Configures the primary from the dependency injection container for a named . The . An that can be used to configure the client. The type of the . The handler type must be registered as a transient service. The will be resolved from a scoped service provider that shares the lifetime of the handler being constructed. Adds a delegate that will be used to configure message handlers using for a named . The . A delegate that is used to configure an . An that can be used to configure the client. Configures a binding between the type and the named associated with the . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The . instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Calling will register a typed client binding that creates using the . The typed client's service dependencies will be resolved from the same service provider that is used to resolve the typed client. It is not possible to access services from the scope bound to the message handler, which is managed independently. Configures a binding between the type and the named associated with the . The created instances will be of type . The declared type of the typed client. They type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The type specified by will be instantiated by the . The . instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Calling will register a typed client binding that creates using the . The typed client's service dependencies will be resolved from the same service provider that is used to resolve the typed client. It is not possible to access services from the scope bound to the message handler, which is managed independently. Configures a binding between the type and the named associated with the . The type of the typed client. They type specified will be registered in the service collection as a transient service. The . A factory function that will be used to construct the typed client. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Calling will register a typed client binding that creates using the provided factory function. Configures a binding between the type and the named associated with the . The type of the typed client. They type specified will be registered in the service collection as a transient service. The . A factory function that will be used to construct the typed client. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Calling will register a typed client binding that creates using the provided factory function. Sets the which determines whether to redact the HTTP header value before logging. The . The which determines whether to redact the HTTP header value before logging. The . The provided predicate will be evaluated for each header value when logging. If the predicate returns true then the header value will be replaced with a marker value * in logs; otherwise the header value will be logged. Sets the collection of HTTP headers names for which values should be redacted before logging. The . The collection of HTTP headers names for which values should be redacted before logging. The . Sets the length of time that a instance can be reused. Each named client can have its own configured handler lifetime value. The default value is two minutes. Set the lifetime to to disable handler expiry. The default implementation of will pool the instances created by the factory to reduce resource consumption. This setting configures the amount of time a handler can be pooled before it is scheduled for removal from the pool and disposal. Pooling of handlers is desirable as each handler typically manages its own underlying HTTP connections; creating more handlers than necessary can result in connection delays. Some handlers also keep connections open indefinitely which can prevent the handler from reacting to DNS changes. The value of should be chosen with an understanding of the application's requirement to respond to changes in the network environment. Expiry of a handler will not immediately dispose the handler. An expired handler is placed in a separate pool which is processed at intervals to dispose handlers only when they become unreachable. Using long-lived instances will prevent the underlying from being disposed until all references are garbage-collected. Extension methods to configure an for . Adds the and related services to the . The . The . Adds the and related services to the and configures a named . The . The logical name of the to configure. An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. Use as the name to configure the default client. Adds the and related services to the and configures a named . The . The logical name of the to configure. A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. Use as the name to configure the default client. Adds the and related services to the and configures a named . The . The logical name of the to configure. A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. Use as the name to configure the default client. Adds the and related services to the and configures a binding between the type and a named . The client name will be set to the type name of . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The client name will be set to the type name of . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The type specified will be instantiated by the The . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The . The logical name of the to configure. An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Use as the name to configure the default client. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The type specified will be instantiated by the The . The logical name of the to configure. An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Use as the name to configure the default client. Adds the and related services to the and configures a binding between the type and a named . The client name will be set to the type name of . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The . A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The client name will be set to the type name of . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The . A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The client name will be set to the type name of . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The type specified will be instantiated by the The . A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The client name will be set to the type name of . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The type specified will be instantiated by the The . A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The . The logical name of the to configure. A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Use as the name to configure the default client. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The . The logical name of the to configure. A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Use as the name to configure the default client. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The type specified will be instantiated by the The . The logical name of the to configure. A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Use as the name to configure the default client. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The type specified will be instantiated by the The . The logical name of the to configure. A delegate that is used to configure an . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Use as the name to configure the default client. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The . A delegate that is used to create an instance of . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The . The logical name of the to configure. A delegate that is used to create an instance of . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The . A delegate that is used to create an instance of . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. Adds the and related services to the and configures a binding between the type and a named . The type of the typed client. The type specified will be registered in the service collection as a transient service. See for more details about authoring typed clients. The implementation type of the typed client. The . The logical name of the to configure. A delegate that is used to create an instance of . An that can be used to configure the client. instances that apply the provided configuration can be retrieved using and providing the matching name. instances constructed with the appropriate can be retrieved from (and related methods) by providing as the service type. A builder for configuring named instances returned by . Gets the name of the client configured by this builder. Gets the application service collection. Pretty print a type name. The . true to print a fully qualified name. true to include generic parameter names. true to include generic parameters. Character to use as a delimiter in nested type names The pretty printed type name. Extensions methods for . Creates a new using the default configuration. The . An configured using the default configuration. Extensions methods for . Creates a new using the default configuration. The . An configured using the default configuration. A factory abstraction for a component that can create instances with custom configuration for a given logical name. A default can be registered in an by calling . The default will be registered in the service collection as a singleton. Creates and configures an instance using the configuration that corresponds to the logical name specified by . The logical name of the client to create. A new instance. Each call to is guaranteed to return a new instance. It is generally not necessary to dispose of the as the tracks and disposes resources used by the . Callers are also free to mutate the returned instance's public properties as desired. A factory abstraction for a component that can create instances with custom configuration for a given logical name. A default can be registered in an by calling . The default will be registered in the service collection as a singleton. Creates and configures an instance using the configuration that corresponds to the logical name specified by . The logical name of the message handler to create. A new instance. The default implementation may cache the underlying instances to improve performance. The default implementation also manages the lifetime of the handler created, so disposing of the returned by this method may have no effect. Throws an if is null. The reference type argument to validate as non-null. The name of the parameter with which corresponds. The '{0}' must not contain a null entry. The '{0}' property must be null. '{1}' instances provided to '{2}' must not be reused or cached.{3}Handler: '{4}' The '{0}' must not be null. The handler lifetime must be at least 1 second. Attribute used to indicate a source generator should create a function for marshalling arguments instead of relying on the runtime to generate an equivalent marshalling function at run-time. This attribute is meaningless if the source generator associated with it is not enabled. The current built-in source generator only supports C# and only supplies an implementation when applied to static, partial, non-generic methods. Initializes a new instance of the . Name of the library containing the import. Gets the name of the library containing the import. Gets or sets the name of the entry point to be called. Gets or sets how to marshal string arguments to the method. If this field is set to a value other than , must not be specified. Gets or sets the used to control how string arguments to the method are marshalled. If this field is specified, must not be specified or must be set to . Gets or sets whether the callee sets an error (SetLastError on Windows or errno on other platforms) before returning from the attributed method. Specifies how strings should be marshalled for generated p/invokes Indicates the user is suppling a specific marshaller in . Use the platform-provided UTF-8 marshaller. Use the platform-provided UTF-16 marshaller.