Search code examples
asp.net-mvcasp.net-web-apiasp.net-mvc-routing

The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint:


I wanted to use attribute routing. My code is:

[Route("api/ws/{parm: myClass}")]
public void Post(myClass parm)
{ ... }

This resulted in an exception in WebApiConfig.Register as follows:

The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: ' myClass'.

What could be the cause of this error?

myClass is a complex object, ie not a simple value type but a class with multiple properties. Are such parameters allowed?


Solution

  • No, you can't use objects in routing attributes; this article has a table with a full list of allowed attribute types.