Multiple optional parameters with in-between empty parameters in Web API attribute routing

35 views Asked by At

This is in .NET 6

The Action method:

[HttpGet("GetCustomers/{customerName?}/{customerNumber?}/{customerSignature?}")]
public async Task<IEnumerable<Customer>> GetCustomers(string customerName = null, string customerNumber = null, string customerSignature = null)
{

This url hits the method:

https://localhost:44378/api/Customer/GetCustomers/A/B/C

But below url doesn't hit the method:

https://localhost:44378/api/Customer/GetCustomers/A//C

Any solution?

0

There are 0 answers