This localhost page can’t be found webpage was found for the web address: http://localhost:5254/ HTTP ERROR 404
In ASP.NET CORE WebAPI project, it does not configure default route or serve default document for root URL path, which cause above issue.
If you check the code of your API controller, you might find that the routes like below are defined.
[ApiController]
[Route("[controller]")]
or
[ApiController]
[Route("api/[controller]")]
To access specific endpoint, please check the actual route defined on that endpoint, you may need to include [controller] and [action] info in URL while you make request(s).
2
Answers
solution: add localhost/swagger,
vscode doesn't show swagger url on startup
In ASP.NET CORE WebAPI project, it does not configure default route or serve default document for root URL path, which cause above issue.
If you check the code of your API controller, you might find that the routes like below are defined.
or
To access specific endpoint, please check the actual route defined on that endpoint, you may need to include
[controller]
and[action]
info in URL while you make request(s).For more information about routing, please check: https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-6.0#attribute-routing-for-rest-apis