Skip to content

Conversation

@vlaicu95
Copy link

Content-Type is always set by default to "text/html" in the constructor of Response class.
If you want to create a response with a image or something different and you provide the new Content-Type in the headers dictionary passed in the constructor an exception is thrown when it tries to add the new "Content-Type" because the Add method was used. This method checks if the same key is present and throws.

One workaround that I used, was to create the response and manually overwrite because the Headers member is public but this approach forces you not to write inline clean code.

This is definitely a bug and in order to solve it the Add method was replaced with []. In this case the content type can be overwritten and also other headers can be added.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant