help
Root Question Message
[Area("api")]
on all api controllers?Route
to all controllers?/api/whatever
, while all the rest should go to /
. I've read the entire page linked above, but it doesn't really mention such a use case, and suggests no best practices in that regard. /Api
directory and API controllers there lolnamespace Ogma3.Api.V1;
[Route("api/[controller]", Name = nameof(ErrorController))]
[ApiController]
public class ErrorController : ControllerBase
{
[HttpGet]
public ActionResult<Result> OnGet([FromQuery] int? code)
{
var text = code.HasValue
? ReasonPhrases.GetReasonPhrase((int)code)
: "Unknown Error";
return new JsonResult(new Result(code, text))
{
StatusCode = code ?? 0
};
}
public sealed record Result(int? Code, string Reason);
}
[Route("[controller]")]
thoApiController
already makes the class attribute-routed only, no?/api/whatever/...
[Route("blah", Name = nameof(...))]
nameof(WhateverController)
nameof(WhateverController)[.. ^("Controller".Length)]
I guessGetLink(controller = nameof(WhateverController), action = nameof(WhateverController.Action))
?nameof()
approach