asp.net-core - 属性路由方法未调用
问题描述
我在 asp.net core web api 中调用带有字符串参数的方法时遇到问题。该方法不会被调用或调用。
** 我的班级看起来像这样 **
[Route("api/[controller]")]
[ApiController]
public class MyClass : ControllerBase
{
[HttpGet("dispatch_discrepancies/{airwayBillNumber}")]
public List<Discrepancy> GetDispatchDiscrepancies(string airwayBillNumber)
{
....
}
}
下面是我的路线配置。
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
解决方案
推荐阅读
- kubernetes - 为 Kubernetes 集群设置 LetEncrypt HTTPS Traefik Ingress
- c# - 交叉引用的风险
- python - pexpect.spawn 会使用多核自动运行进程吗?
- php - 从同一个按钮重定向和写入?
- npm - Package.json 缺少脚本:stg
- angular - 如何使用组件代替 ionic 4
- curl - 如何正确安装 libcurl 以在 Visual Studio 2017 中使用?
- dart - 在 Flutter 中的屏幕之间传递数据
- sql - 如何在plsql中进行数据透视
- chapel - 如何打印出 Chapel 变量的完全限定类型?