StaticHeaderAttribute Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines a static header to be sent on every API request.
public ref class StaticHeaderAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class StaticHeaderAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Interface | System.AttributeTargets.Method, AllowMultiple=true)>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type StaticHeaderAttribute = class
inherit Attribute
Public NotInheritable Class StaticHeaderAttribute
Inherits Attribute
- Inheritance
- Attributes
[AutoClient("MyClient")]
[StaticHeader("X-MyHeader", "MyHeaderValue")]
interface IMyDependencyClient
{
[Get("/api/users")]
[StaticHeader("X-GetUsersHeader", "Value")]
public Task<Users> GetUsers(CancellationToken cancellationToken = default);
}
Injects a static header to be sent with every request. When this attribute is applied to an interface, then it impacts every method described by the interface. Otherwise, it only affects the method where it is applied. The header name must not be null or empty. The value, on the other hand, can be empty, but not null.
Static |
Initializes a new instance of the StaticHeaderAttribute class. |
Produkt | Versioner |
---|---|
.NET | 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (package-provided), 10 (package-provided) |
Feedback om .NET
.NET är ett öppen källkod projekt. Välj en länk för att ge feedback: