Skip to content

Document ProductInfoHeaderValue constructors #3274

Open

Description

I'm sometimes making HTTP requests to various APIs. Quite often, they require specifying the User-Agent header. To do that with HttpClient, I have to create ProductInfoHeaderValue, e.g.:

ProductInfoHeaderValue value =;
var client = new HttpClient { DefaultRequestHeaders = { UserAgent = { value } } };

My problem is that creating valid ProductInfoHeaderValue is not obvious and the documentation for its constructors does not explain which constructor I should use or what are the requirements for the string parameters.

As an example, if I try new ProductInfoHeaderValue("svick's awesome tool"), it throws "FormatException: The format of value 'svick's awesome tool' is invalid." This doesn't help me figure out what the valid values are, which is why I think documenting this is important.

This article explains the rules for User-Agent values and might be helpful when resolving this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Pri3Indicates issues/PRs that are low priorityarea-System.Netdoc-enhancementImprove the current contenthelp wantedGood for community contributors to help [up-for-grabs]

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions