Converting my comment into an answer to complement @Kiran Chala's answer as it seems helpful for the audiences-
When we mark a parameter as optional in the action uri using ?
character then we must provide default values to the parameters in the method signature as shown below:
MyMethod(string name = "someDefaultValue", int? Id = null)