I create a Web Api in asp.net core this the content of Api:
namespace CPTestApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class EnergyController : ControllerBase
{
private readonly CP_FinalContext _context;
public EnergyController(CP_FinalContext context)
{
_context = context;
}
[HttpGet]
[Route("Energy")]
public async Task<ActionResult<IEnumerable<TblEnergyDetail>>> TblEnergyDetail()
{
return await _context.TblEnergyDetails.ToListAsync();
}
}
}
So when I try to call the Energy by browser or Postman, by this url https://localhost:(port)/api/Energy, it gets me 404 error, what is the problem?
Any help will be highly appreciated!
Thank You!