.net core web api development in mac OS using VS Code
Getting "This localhost page can’t be found" error in browser when opening localhost:5200 in browser after running 'donet run' command. The server is running in 5200 port but browser can't find it. Help me with this.
9 Replies
in the console I can see that the server is running at 5200 port
Anyone faced similar issue?
there is no error actually
there is no path specified for default route, therefore you get 404
what do you have in Program.cs and controller attributes ?
A Web API usually has no web pages to serve, so 404 is natural.
This is my program.cs file
Also i have this controller
@Lex Li @atakancracker - looks like issue is someth8ngs else as I already have the controller as above
@Lex Li @atakancracker http://localhost:5200/WeatherForecast - this worked
Web API projects are in general serving data via different HTTP requests/responses, so you should use a tool like curl to access the data, or use Swagger which is de facto approach. You found that URL worked, simply because your web browser sent the expected HTTP GET request at
/WeatherForecast
, and your Web API instance responded with a piece of JSON. Like @atakancracker commented, nothing is there to serve HTTP GET request at /
so 404 is expected.