【发布时间】:2020-03-16 16:39:29
【问题描述】:
在我的 startup.cs 类中,我有:
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
我的控制器目前看起来像这样:
[Microsoft.AspNetCore.Components.Route("api/my-test")]
public class MyTestController : ControllerBase
{
[HttpGet]
[Route("{confirmationCode}")]
public async Task<IActionResult> Get(string confirmationCode)
{
return Ok($"The confirmation code is: {confirmationCode}");
}
}
如何在 MyTestController 上调用 Get 操作,并从如下所示的路由 URL 访问作为 URL 的一部分传入的确认代码: /api/my-test/abc123
【问题讨论】:
标签: asp.net .net asp.net-mvc asp.net-web-api .net-core