title: Changing Response content-type
body: <p>Using C#, .NET Core 3.1.</p>
  <p>I am trying to set the response content-type header value for particular controllers (not all controllers in the project). At the moment, I have this but I am not sure if I am doing it right. Am I in the right direction with this code I have?</p>
  <pre class="lang-cs prettyprint-override"><code>public class MyCustomFilter: ActionFilterAttribute
  {
      public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
      {
         actionExecutedContext.Response.Headers.Add(&quot;testAddingHeader&quot;, &quot;123456&quot;);
         //Can I do change Content-Type here too?
      }
  }
  </code></pre>
  <p>In my controller class:</p>
  <pre><code>[MyCustomFilter()] // Do I need to use [ServiceFilter(typeof(MyActionFilterAttribute))]?
  public class SampleController : Controller
  {
      public IActionResult Index()
      {
          return Ok(&quot;Hello World.&quot;);
      }
  </code></pre>
  <p><strong>UPDATE</strong>
  I followed the better suggestion from Silkfire.</p>
  <p>This worked for me but I get a 406 from the browser. Does it mean the content was delivered to the browser but is unwilling to render it as it was not part of the accepted content type (specified in request)?  Key thing is that the response made it to the client. Thanks!</p>
  <pre><code>    [Produces(&quot;application/somethingcustom&quot;)]
  </code></pre>
  <p>I inspected the response to the browser via Fiddler. Seems that the raw body content is empty - does that meant the server is doing some changes to the response body and not just simply changing the response content-type header?</p>
  <p><strong>UPDATE 2</strong>
  Found the reason why!
  Looks like I need to write my own custom formatter as I noticed this when accessing the controller action:</p>
  <p><code>No output formatter was found for content types  to write the response.</code></p>