Add multiple Headers via AddHeader


it’s basically not a question but a clarification to a behaviour that might not be obvious (and took me some time to discover).

You should state in the docs/examples, that one has to add ONE AddHeader-Attribute for EACH single Header-Field even though the Visual Studio code completion (correctly) suggest that the attribute could be initialized with multiple values.

After looking at the sourcecode of AddHeaderAttribute its clear its working that way, but a simple example would help to save some research-time.


    // Doesn't work
    [AddHeader(ContentType = "image/png", ContentEncoding = "base64")]
    public string Get(TestRequest request)
        return "123";

    // Works
    [AddHeader(ContentType = "image/png")]
    [AddHeader(ContentEncoding = "base64")]
    public string Get(TestRequest2 request)
        return "456";

cheers Michael

It is called [AddHeader], the properties are just typed access to common headers so setting multiple overwrites the header. I’ve included examples of adding 2 headers in the docs.

Note: you can attributes in-line like:

[AddHeader(ContentType = "image/png"), AddHeader(ContentEncoding = "base64")]
public string Get(TestRequest2 request) => ...