0

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!

1 Answer 1

1

Your web API Basic Route is

api/Energy

for routing to Energy method you should route the request to

 api/Energy/Energy
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.