1

Making the first API with the sample code from ASP.NET Web API:

In the WebApiConfig.cs, there is a route template:

            routeTemplate: "v1/{controller}/{text}",
            defaults: new { text= RouteParameter.Optional }

If I use a query string like "v1/demo/date1=x1&date2=x2", x1 and x2 values can be extracted and passed on to display the API response correctly.

But if I use a query string starting with a question mark, such as "v1/demo/?date1=x1&date2=x2", the API response always displays the initial values of x1 and x2, which are null. How can I disable the overarching setup for the question mark here? Thanks for your explanation in advance.

kevin
  • 11
  • 3
  • 1
    Tris on this pages (https://stackoverflow.com/questions/19956974/webapi-2-0-routes-not-matching-with-query-parameters) says: " Now in the WebApi2.0 AttributeRouting framework, attempting to add a ? in a Route definition throws the exception." – kevin May 24 '18 at 04:00

0 Answers0