1

I am using attribute routing.
Here is my controller:

[HttpGet("Flights/{Id?}")]
public IActionResult GetFlights(string Id)
{
    var flightroute= _myService.GetFlightsWithRoutes(Id);
    if (flightroute != null)
    {
        return Ok(flightroute);
    }

    return NotFound();
}

I able to perform

https://localhost:44374/air/Flights/AI-109

But this shows 404 Not Found response

https://localhost:44374/air/Flights?Id=AI-109

How can I enable both routing, or can I? I want both routes to call same action method.

Anand Maurya
  • 101
  • 2
  • 9
  • You want both routes to call same action? – Valeriu Seremet Dec 04 '19 at 09:42
  • 3
    Possible duplicate of [Query string not working while using attribute routing](https://stackoverflow.com/questions/22642874/query-string-not-working-while-using-attribute-routing) – GSerg Dec 04 '19 at 09:43

0 Answers0