"id:int?" is not a valid route template, it's just a string literal (like as if you expected the Request Url to literally look like http://server/api/MyController/id:int? which is not allowed.
Funnily enough, that's only because of the ? character; if you removed that then the literal would be allowed (even though it's useless).
Whereas "{id:int?}" is a proper route template and will work correctly, i.e. the Url will look like http://server/api/MyController/42 or http://myserver/api/MyController/ which will give the default value
So the method should be like this:
// GET: api/mycontroller/{id}
[HttpGet("{id:int?}")]
public IActionResult Get(int id = 0)
{
// Some logic here...
}
"{id?:int}"whereby you are indicating thatidis optional and the type isint. So you are missing the{and}and also the?is in the wrong place as far as I can tell.{and}, because I just tested it and it works fine with{and}but without them I see the same error. So it should be"{id:int?}...otherwise "id:int?" is being treated as a literal string, not a route template.