How to fix Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing

This post shows you How to solve the problem Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing when changing ASP.NET Core 2.2 to 3.0
Warning MVC1005 Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing. To continue using 'UseMvc', please set 'MvcOptions.EnableEndpointRouting = false' inside 'ConfigureServices'.

Open your Startup class, then modify your code as shown below.

app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

If you get an error as shown below when running your project.

'EndpointRoutingMiddleware matches endpoints setup by EndpointMiddleware and so must be added to the request execution pipeline before EndpointMiddleware. Please add EndpointRoutingMiddleware by calling 'IApplicationBuilder.UseRouting' inside the call to 'Configure(...)' in the application startup code.'

You need to add to the Configure method.

app.UseRouting();

ASP.NET Core 3.0 uses a refined endpoint routing which will generally give more control about routing within the application. Endpoint routing works in two separate steps:

In a first step, the requested route is matched again the configured routes to figure out what route is being accessed.

In a final step, the determined route is being evaluated and the respective middleware, e.g. MVC, is called.

These are two separate steps to allow other middlewares to act between those points. That allows those middlewares to utilize the information from endpoint routing, e.g. to handle authorization, without having to execute as part of the actual handler (e.g. MVC).