I have the following API endpoint:
[AllowAnonymous]
[HttpPost("login")]
public async Task<IActionResult> Authenticate([FromBody] LoginViewModel credentials)
{
try
{
var result = await _facade.SomeMethodThatFailsAndThrowsCustomCode4001(credentials);
return Ok(result);
}
catch (CustomException cEx)
{
return StatusCode(4001, new { Message = cEx.FriendlyMessage ?? "" }); //Message = Our custom user friendly message
}
}
When hosted on external server through IIS, these messages were returned perfectly. When hosted on Azure, the messages are not showing, and this is the response received:
{
"Message": ""
}
I have read about Policies allowed in on-error, but this means I will need to register my .Net Core
API with the API management in Azure, and not sure if this is necessary.
What would be required to be configured to allow our custom messages returned through our API hosted in Azure?