title: Returning custom HttpResponseMessage as IActionResult
body: <p>I have a web api which returns <code>IActionResult</code>.</p>
  
  <p>I return <code>FileContentResult</code> from this api like this</p>
  
  <pre><code>return new FileContentResult(model.Content, ContentType)
  {
      EnableRangeProcessing = true
  };
  </code></pre>
  
  <p>I have a requirement in which I now want to control <code>StatusCode</code> myself, rather than <code>FileContentResult</code> decide itself.</p>
  
  <p>I don't find any way to do this. </p>
  
  <p>Basically I want to return my own designed <code>HttpResponseMessage</code> in which I can set headers and other stuff myself.</p>
  
  <p>But I don't find any way to do this for <code>IActionResult</code> type.</p>
  
  <p>The only thing that I thought could work is to use <code>ResponseMessageResult</code> something like this</p>
  
  <pre><code>var content = new ByteArrayContent(bytesWithValidationData);
  var response = new HttpResponseMessage();
  response.Content = content;
  response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
  response.StatusCode = HttpStatusCode.PartialContent;
  response.Content.Headers.ContentRange = new ContentRangeHeaderValue(from, to);
  
  return new ResponseMessageResult(response);
  </code></pre>
  
  <p>But its response is not same as HttpResponse, it just returns json result with <code>HttpResponseMessage</code> object details but does not actually return Http response considering content type etc. where I can download the file. </p>
  
  <p>It gives result like this</p>
  
  <p><a href="https://i.stack.imgur.com/y1vIh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y1vIh.png" alt="enter image description here"></a></p>
  
  <p>Is there any way I can return my designed file result type http response?</p>