Hello,
I was testing the wildcard
routing option when I encountered a small issue (unrelated to wildcard
): I have a route that has a few parameters in the url and the routing matches the request even if I do not give it the parameters.
For example, my request is defined with the route /routeWithOptParameters/{Name}/na/{Age}
and if I hit it with the following url /routeWithOptParameters/Bob/na/28
I get the expected behavior. However if I only use the url /routeWithOptParameters
my service is still called but with the default values for Name
and Age
.
I was surprised by this so I wanted to verify if I made a mistake or if this was the expected behavior. I tested with the latest version (4.0.60). Below is the code I used in a sample project.
[Route("/routeWithOptParameters/{Name}/na/{Age}", Verbs = "Get")]
[DataContract]
public class RouteWithOptParameters : IReturn<string>
{
[DataMember]
[ApiMember(IsRequired = true)]
public string Name { get; set; }
[DataMember]
public int Age { get; set; }
}
public string Any(RouteWithOptParameters request)
{
return request.GetType().Name + ": Name (" + request.Name + ") / Age (" + request.Age + ") \n" + DateTime.Now.ToString();
}