The constraint reference 'string' could not be resolved to a type. (netcoreapp3.0)

In case you use something like

[HttpGet("example/{param1:string}/{param2:Guid}")]

change it to

[HttpGet("example/{param1}/{param2:Guid}")]

because ":string" is actually interpreted as a regex-validation-constraint and not a type definition and guess what, everything is reaching the server as string and there is no string-regex-validator :)


I also encountered this recently. The fix for me as to use "alpha" as a replacement for the string type:

[HttpGet("example/{param1:alpha}")]

This was documented in the Microsoft documentation.