【发布时间】:2020-08-20 00:06:57
【问题描述】:
您好,我是 Web API 的初学者。所以我创建了一个这样的简单函数测试。
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}
[HttpGet]
[Route("api/[controller]/test")]
public string[] test()
{
return new string[] { "test1","test2" };
}
在这里,我创建了一个带有路由规范的自定义方法测试。但是当我尝试 https://localhost:44389/api/values/test 时,它会显示 {"errors":{"id":["The value 'test' is not valid."]},"title":"One or more validation errors occurred.","status":400,"traceId":"8000001f-0002-e900-b63f-84710c7967bb"}
请告诉我如何解决这个问题。
【问题讨论】:
标签: asp.net-core asp.net-web-api asp.net-core-webapi