title: How to pass Location header to response with command(API) and query(odata) controllers
body: <p><strong>Scenario</strong></p>
  
  <p>Hi I have command API controller written in ASP.Net core 2.2. Controller inherited from <em>ControllerBase</em> and has attribute <em>ApiController</em>. I would like to add Location header. I have also query odata controller. <em>Odata version: 7.2.2</em>.</p>
  
  <p><strong>Odata codes:</strong></p>
  
  <p>My Odata controller:</p>
  
  <pre><code>[ODataRoutePrefix("categories")]
  public class ODataCategoriesController : ODataController
  </code></pre>
  
  <p>Odata Get action:</p>
  
  <pre><code>[EnableQuery]
  [ODataRoute("{id}")]
  public async Task&lt;ActionResult&lt;Category&gt;&gt; GetAsync(Guid id)
  </code></pre>
  
  <p><strong>Startup</strong></p>
  
  <pre><code>opt.EnableEndpointRouting = false;
  ...
  app.UseHttpsRedirection();
  app.UseMvc(options =&gt;
  {
       options.EnableDependencyInjection();
       options.Select().Filter().OrderBy().Count().Expand().MaxTop(100).SkipToken();
       options.MapODataServiceRoute("odata", "api/odata", GetExplicitEdmModel());
  });
  </code></pre>
  
  <p><strong>Tried</strong></p>
  
  <p>I've tried using CreatedAtAction but I received: <em>InvalidOperationException: No route matches the supplied values.</em> </p>
  
  <p>In my POST controller:</p>
  
  <pre><code>return CreatedAtAction("Get", "ODataCategories", new { id= categoryResponse.Id }, categoryResponse);
  </code></pre>
  
  <p><strong>Tried 2</strong></p>
  
  <p>I have also tried with return Location header manually. But I recieved:
  <em>Header is not present in response.</em></p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>    [HttpPost]
      [ProducesResponseType((int)HttpStatusCode.Created)]
      [ProducesResponseType((int)HttpStatusCode.BadRequest)]
      public async Task&lt;ActionResult&lt;CreateCategoryResponse&gt;&gt; PostCategory(
          [FromBody]CreateCategoryCommand createCategoryCommand)
      {
          CreateCategoryResponse categoryResponse =
              await _mediator.Send(createCategoryCommand);
  
          if (categoryResponse == null)
          {
              return BadRequest();
          }
  
          HttpContext.Response.Headers["Location"] = 
              $"SomeBuiltLocation";
          return Created("", categoryResponse);
      }
  </code></pre>
  
  <p><strong>Summary</strong></p>
  
  <p>I am looking for solution which enable me to include Location header. It does not matter if it be with CreatedAt or by hand.</p>