简体   繁体   中英

Attribute routing with multiple parameters

Here is the method in my controller which is called:

app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });

Your route: [HttpGet("price/{priceone?}/{pricetwo?}")] doesn't match your request /price/30.0&35.0 . This is why you are getting a bad request.

Correct request path would be /price/30.0/35.0

You can alternaliverly pass in these values as a query string eg: /price/?priceone=30.5&pricetwo=35.0

and then add [FromQuery] in your Get method like this: public IActionResult ByPrice([FromQuery] double? priceone, [FromQuery] double? pricetwo)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM