ASP.NET Core This localhost page can’t be found

I solved this problem when I realized I had accidentially removed the default route in the StartUp class' Configure method:

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

This is similar to @ToMissTheMarc answer, but shows how to define routes in .Net Core version 3.0

I was having a similar problem when trying to hit my API endpoint https://localhost:44380/api/Restaurants

In order to map my routes for an API controller class that inherited from the ControllerBase class, I needed to add the line endpoints.MapControllers to Configure method of Startup.cs class, as follows:

        //Pre .NET core 3.0 way of doing things
        //app.UseMvc(routes => {<some routing stuff here>});

        //.NET core 3.0 way
        app.UseRouting();
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapRazorPages(); //Routes for pages
            endpoints.MapControllers(); //Routes for my API controllers
        });

If the answer above doesn't work or you're coming from the .NET Web API tutorial, this might help. So for me, I removed the launchUrl property from launchSettings.json because I wanted to use a static page (per the instructions of the tutorial I'm following) and forgot to add 2 lines in my haste. I finally went back and looked over it and this solved my issue.

Open the Startup.cs file and inside public void Configure... add the following above the app.UseMvc(); line:

app.UseDefaultFiles(); app.UseStaticFiles();