C
C#2mo ago
abdesamed

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

No description
4 Replies
abdesamed
abdesamed2mo 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
Angius2mo 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
abdesamed2mo 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
Angius2mo ago
Yep