HTTP response status codes have so much importance in REST API’s.
In any case if you want to return a status code from your ASP.NET Core API, all you have to do is in your controller method,

1returnStatusCode(StatusCodes.Status500InternalServerError);

StatusCode is from Microsoft.AspNetCore.Mvc.ControllerBase.StatusCode and StatusCodes from Microsoft.AspNetCore.Http.StatusCodes.
The above code will return a 500 status code. Similar way, you can return any other status code. For the complete list,

Written by Abhith RajanFollow @AbhithRajan
Abhith Rajan is an aspiring software engineer with more than 7 years of experience and proven successful track record of delivering technology-based products and services.
Buy me a coffee ☕