I have a problem of url routing in ASP.NET Core web api. When the URL contins dot (.) it returns 404 not found. For example,
The code that doesn't work with email but work with no dot
public class TestController : Controller{
{
[HttpGet]
[Route("{id:int}")]
public IActionResult Get(int id)
{
//whatever
}
[HttpGet]
[Route("{id:int}/{name:alpha}")]
public IActionResult Get(int id, string name)
{
//whatever
}
}
However, this works
http://localhost:9030/api/test/getbyname/109/[email protected]
public class TestController : Controller{
{
[HttpGet("GetById/{id}")]
public IActionResult Get(int id)
{
//whatever
}
[HttpGet("GetByName/{id}/{name}")]
public IActionResult Get(int id, string name)
{
//whatever
}
}
How to solve that problem?
[email protected]would not be valid regardless. Did you forget to url encode the@? urlencoder.org@like that. You should url encode it.