gpt4 book ai didi

c# - ASP.NET Core 中 Controller 路由中的方括号

转载 作者:行者123 更新时间:2023-12-03 15:55:25 27 4
gpt4 key购买 nike

Controller 中的方括号是什么意思路线 在 ASP.NET Core 中是什么意思?

例如。 路线(“[ Controller ]”)这里:

    [ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
...
}

最佳答案

它是 Controller 名称的占位符(称为 token 替换),不带后缀 Controller .在你的情况下 WeatherForecastController , [controller]将自动替换为 WeatherForecast .
您可以在 documentation 中找到更多详细信息.

关于c# - ASP.NET Core 中 Controller 路由中的方括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59523672/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com