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.
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.