【发布时间】:2020-06-06 06:43:22
【问题描述】:
重现步骤:
- 创建一个新的 .NET Core Web API 项目
-
转到生成的
WeatherForecastController,将类更新为[ApiController] [Route("[controller]")] public class WeatherForecastController : ControllerBase { [HttpGet("{id}")] public async Task<ActionResult<object>> GetById(int id) { return Ok(null); } } -
创建第二个控制器
[ApiController] [Route("[controller]")] public class FooController : ControllerBase { [HttpPost] public async Task<ActionResult<object>> Create() { return CreatedAtAction(nameof(WeatherForecastController.GetById), new { id = 1 }, null); } } 构建项目,应该没问题
-
Rider 在
Create路线出现错误无法解析操作“GetById”
如你所见
这很烦人,因为 IDE 也在项目资源管理器中提供了它
虽然代码运行良好。那么我的代码很糟糕,我应该改进它吗?是bug吗?
【问题讨论】:
标签: c# asp.net-core rider