Reputation:
I have a ASP .NET MVC controller that receive two decimal parameters:
[HttpGet, Route("stores/{latitude}/{longitude}")]
public void GetStores(decimal latitude, decimal longitude)
{
...
}
This controller not working (404 error) when I invoke this url:
http://localhost:16959/store/stores/40.5479397/-3.6116505
But... if I modify my controller, and I add "/" in route string, I can invoke this url correctly (Postman):
[HttpGet, Route("stores/{latitude}/{longitude}/")]
public void GetStores(decimal latitude, decimal longitude)
{
...
}
http://localhost:16959/store/stores/40.5479397/-3.6116505/
The problem now, is Swagger not recognize this slash "/" and never found controller.
My question is... What's the better way to solve this problem? Pass values in the body request? Add slash in the second parameter?
Upvotes: 0
Views: 1570
Reputation: 1
You don't have to use Route("stores/{latitude}/{longitude}/") or modify URL template.
Just use <input>
with name and then submit as URL Query string
<input Name="Latt" Type="Text" placeholder="Lattitude">
<input Name="Lang" Type="Text" placeholder="LAngitude">
<input Type="Submit" >
use the above code in the begin form
If there is any problem in the controller input specification use like below
Public ActionResult Login (String Latt,String Long)
{
decimal latt = (decimal)Latt;
decimal long = (decimal)Long;
(put your code here)
}
Upvotes: 0
Reputation: 214
Have you tried passing the values in the query string? E.g
http://localhost:16959/store/stores?latitude=40.5479397&longitude=-3.6116505
Upvotes: 1