'DefaultInlineConstraintResolver' 类型的内联约束解析器无法解析以下内联约束:
The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint:
我想使用属性路由。我的代码是:
[Route("api/ws/{parm: myClass}")]
public void Post(myClass parm)
{ ... }
这导致 WebApiConfig.Register
中的异常如下:
The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: ' myClass'.
导致此错误的原因可能是什么?
myClass
是一个复杂的对象,即不是简单的值类型而是具有多个属性的 class。允许这样的参数吗?
不,不能在路由属性中使用对象; this article 有一个 table,其中包含允许的属性类型的完整列表。
我想使用属性路由。我的代码是:
[Route("api/ws/{parm: myClass}")]
public void Post(myClass parm)
{ ... }
这导致 WebApiConfig.Register
中的异常如下:
The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: ' myClass'.
导致此错误的原因可能是什么?
myClass
是一个复杂的对象,即不是简单的值类型而是具有多个属性的 class。允许这样的参数吗?
不,不能在路由属性中使用对象; this article 有一个 table,其中包含允许的属性类型的完整列表。