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.

1
  • 1
    Tris on this pages (stackoverflow.com/questions/19956974/…) says: " Now in the WebApi2.0 AttributeRouting framework, attempting to add a ? in a Route definition throws the exception." Commented May 24, 2018 at 4:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.