"code": "UnsupportedApiVersion",
"message": "The HTTP resource that matches the request URI 'http://xxxx/api/v1/Test/uploadAction.gif?args=123' with API version '1' does not support HTTP method 'GET'.
怎么回事?
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
[EnableCors("AllowAllOrigin")]
[ApiController]
public class TestController : ControllerBase
{
[HttpGet("/uploadAction.gif")]
public async Task<IActionResult> UploadItems(string args, string app)
{
...
}
}
是我的HttpGet里的Route写错了,多了一个 /
这说的很明确了勒,你这使用ApiVersion的版本不支持,升级一下吧。
看一下ConfigureServices
有没有配置默认版本:
services.AddApiVersioning(option=>
{
option.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0);
option.AssumeDefaultVersionWhenUnspecified = true;
option.ReportApiVersions = true;
});
已经写过了。