Description
In version 1 of my API, I defined PUT and POST methods for the same route. In version 2, I removed the PUT method and left only POST. Now when I send a PUT request with version 2, I get a response with the 405 Method Not Allowed status, as expected. However, the response has an unexpected "Allow: POST, PUT" header. That should be just "Allow: POST" because the PUT method is no longer allowed in version 2.
Using Microsoft.AspNet.WebApi.Versioning/4.1.1 (i.e. release v5.0.0 in this repo) with Microsoft.AspNet.WebApi/5.2.7 (i.e. tag v3.2.7 in aspnet/AspNetWebStack) on .NET Framework. I defined an API controller with two action methods:
[ApiVersion("1")]
[ApiVersion("2")]
public class FileController : ApiController
{
[HttpPost]
[Route("v{apiVersion:apiVersion}/newFile")]
public async Task<HttpResponseMessage> NewFile(HttpRequestMessage request) { … }
[Obsolete("Use the POST method.")]
[HttpPut]
[Route("v{apiVersion:apiVersion}/newFile")]
[ApiVersion("1")] // Removed in version 2.
public Task<HttpResponseMessage> NewFilePut(HttpRequestMessage request) { … }
}
I tried moving the ApiVersion attributes from the FileController class to the NewFile method but that made no difference.