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. 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. Indicates that certain members on a specified are accessed dynamically, for example through . This allows tools to understand which members are being accessed during the execution of a program. This attribute is valid on members whose type is or . When this attribute is applied to a location of type , the assumption is that the string represents a fully qualified type name. When this attribute is applied to a class, interface, or struct, the members specified can be accessed dynamically on instances returned from calling on instances of that class, interface, or struct. If the attribute is applied to a method it's treated as a special case and it implies the attribute should be applied to the "this" parameter of the method. As such the attribute should only be used on instance methods of types assignable to System.Type (or string, but no methods will use it there). Initializes a new instance of the class with the specified member types. The types of members dynamically accessed. Gets the which specifies the type of members dynamically accessed. Specifies the types of members that are dynamically accessed. This enumeration has a attribute that allows a bitwise combination of its member values. Specifies no members. Specifies the default, parameterless public constructor. Specifies all public constructors. Specifies all non-public constructors. Specifies all public methods. Specifies all non-public methods. Specifies all public fields. Specifies all non-public fields. Specifies all public nested types. Specifies all non-public nested types. Specifies all public properties. Specifies all non-public properties. Specifies all public events. Specifies all non-public events. Specifies all interfaces implemented by the type. Specifies all members. Suppresses reporting of a specific rule violation, allowing multiple suppressions on a single code artifact. is different than in that it doesn't have a . So it is always preserved in the compiled assembly. Initializes a new instance of the class, specifying the category of the tool and the identifier for an analysis rule. The category for the attribute. The identifier of the analysis rule the attribute applies to. Gets the category identifying the classification of the attribute. The property describes the tool or tool analysis category for which a message suppression attribute applies. Gets the identifier of the analysis tool rule to be suppressed. Concatenated together, the and properties form a unique check identifier. Gets or sets the scope of the code that is relevant for the attribute. The Scope property is an optional argument that specifies the metadata scope for which the attribute is relevant. Gets or sets a fully qualified path that represents the target of the attribute. The property is an optional argument identifying the analysis target of the attribute. An example value is "System.IO.Stream.ctor():System.Void". Because it is fully qualified, it can be long, particularly for targets such as parameters. The analysis tool user interface should be capable of automatically formatting the parameter. Gets or sets an optional argument expanding on exclusion criteria. The property is an optional argument that specifies additional exclusion where the literal metadata target is not sufficiently precise. For example, the cannot be applied within a method, and it may be desirable to suppress a violation against a statement in the method that will give a rule violation, but not against all statements in the method. Gets or sets the justification for suppressing the code analysis message. Specifies that null is allowed as an input even if the corresponding type disallows it. Specifies that null is disallowed as an input even if the corresponding type allows it. Specifies that an output may be null even if the corresponding type disallows it. Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns. Specifies that when a method returns , the parameter may be null even if the corresponding type disallows it. Initializes the attribute with the specified return value condition. The return value condition. If the method returns this value, the associated parameter may be null. Gets the return value condition. Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. Initializes the attribute with the specified return value condition. The return value condition. If the method returns this value, the associated parameter will not be null. Gets the return value condition. Specifies that the output will be non-null if the named parameter is non-null. Initializes the attribute with the associated parameter name. The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. Gets the associated parameter name. Applied to a method that will never return under any circumstance. Specifies that the method will not return if the associated Boolean parameter is passed the specified value. Initializes the attribute with the specified parameter value. The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to the associated parameter matches this value. Gets the condition parameter value. Specifies that the method or property will ensure that the listed field and property members have not-null values. Initializes the attribute with a field or property member. The field or property member that is promised to be not-null. Initializes the attribute with the list of field and property members. The list of field and property members that are promised to be not-null. Gets field or property member names. Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition. Initializes the attribute with the specified return value condition and a field or property member. The return value condition. If the method returns this value, the associated parameter will not be null. The field or property member that is promised to be not-null. Initializes the attribute with the specified return value condition and list of field and property members. The return value condition. If the method returns this value, the associated parameter will not be null. The list of field and property members that are promised to be not-null. Gets the return value condition. Gets field or property member names. 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.