0

I need to pass a decimal value in my URL.

As the example below: URL: http://localhost/4,5/test

Problem is that my value is passing as 0

[Route("api/TableItemsMain/{quantity:decimal}/{name}
public void Post()
{

}

Is there any method I can pass decimal values? Or it is better to convert my comma to dot before in my URL?

Useme Alehosaini
  • 2,998
  • 6
  • 18
  • 26
  • 1
    ASP.NET will use the current Thread Culture by default when parsing numeric values in URL routes. So a user with `Accept-Language: de-DE` will have different behaviour than a user with `Accept-Language: en-US`. If you need consistent behaviour then you should set `quantity:string` and parse it yourself with an explicit `CultureInfo`. – Dai Dec 20 '20 at 09:40
  • check this https://stackoverflow.com/questions/21944225/pass-decimal-as-value-in-webapi-2-url – Dhrumil shah Dec 21 '20 at 09:19

0 Answers0