问题
I got a Web Api project, and I want to call a api controller through this URL:
Http://localhost:3030/GetByCoordinates/[[0,1],[1,1],[1,0],[0,0]]
It works fine, but when I try to add a double number (like 1.1 instead of 1) the browser throws 404 not found exception, because the dot make it look like another address.
How can i handle doubles ?
回答1:
Try adding '/' at the end of the URL, e.g.
Http://localhost:3030/GetByCoordinates/[[0,1],[1,1.1],[1,0],[0,0]]/
Reference: Why is my Web API method with double args not getting called?
回答2:
This isn't strictly the query string, but unless you can configure your MVC project (or, more specifcally, probably IIS) to allow/manage certain mappings (or not to manage them, in a given case perhaps) then you should be able to translate the character from one form to another.
That is, you could swap periods out for %2E
, and swap them back in on the server side.
来源:https://stackoverflow.com/questions/15528819/passing-double-float-through-url-to-web-api-query-string