C
C#9mo ago
abdesamed

why do we need to specify the route again in handler methods, and why it's absolute

No description
4 Replies
abdesamed
abdesamedOP9mo ago
in this example in the class attribute, we used "api/[controller]", but the handler method has author attribute that uses an absolute path, I don't understand why it exists in the first place, and why its absoulte
Angius
Angius9mo ago
You don't need to
namespace MyBGList.Controllers;

[Route("api/[controller]")]
[ApiController]
public class ErrorController : ControllerBaee
{
[HttpGet("error")]
public IActionResult Error()
{
return Problem();
}
}
namespace MyBGList.Controllers;

[Route("api/[controller]")]
[ApiController]
public class ErrorController : ControllerBaee
{
[HttpGet("error")]
public IActionResult Error()
{
return Problem();
}
}
abdesamed
abdesamedOP9mo ago
thanks, that's what I expected and I was confused by the example from a book I'm reading I expect this to map to api/error/error
Angius
Angius9mo ago
Yep

Did you find this page helpful?