Aspnetcore: Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing. To continue using 'UseMvc', please set 'MvcOptions.EnableEndpointRounting = false' inside 'ConfigureServices'.

Created on 19 Apr 2019  路  7Comments  路  Source: dotnet/aspnetcore

I am getting the following warning from after upgrading an my ASP.NET Core Angular application from ASP.NET Core 3.0 Preview 3 to ASP.NET Core 3.0 Preview 4.

1>Startup.cs(75,13,80,15): warning MVC1005: Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing. To continue using 'UseMvc', please set 'MvcOptions.EnableEndpointRounting = false' inside 'ConfigureServices'.

Then if I set MvcOptions.EnableEndpointRounting = false as follows:

 services.AddMvc(option => option.EnableEndpointRouting = false)
                .AddNewtonsoftJson();

Then the warning goes away. My question is if I want to use EndpointRounting then should I remove the following code:

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

if not then what change I have to make?

Done area-mvc

Most helpful comment

@davidfowl and @rynowak I have created a brand new ASP.NET Core Angular application with .NET Core 3.0 preview 4 SDK and I have found the following:

services.AddMvc(option => option.EnableEndpointRouting = false) .AddNewtonsoftJson();

that means Endpoint Routing is disabled by default on ASP.NET Core 3.0 Angular application. My question is why it is disabled? Does ASP.NET Core 3.0 preview 4 SPA not support Endpoint Routing yet?

All 7 comments

There's a section in this blog post called "Endpoint Routing Updates" that are relevant here. https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-core-3-0-preview-4/

@davidfowl and @rynowak I have created a brand new ASP.NET Core Angular application with .NET Core 3.0 preview 4 SDK and I have found the following:

services.AddMvc(option => option.EnableEndpointRouting = false) .AddNewtonsoftJson();

that means Endpoint Routing is disabled by default on ASP.NET Core 3.0 Angular application. My question is why it is disabled? Does ASP.NET Core 3.0 preview 4 SPA not support Endpoint Routing yet?

@davidfowl and @rynowak I have created a brand new ASP.NET Core Angular application with .NET Core 3.0 preview 4 SDK and I have found the following:

services.AddMvc(option => option.EnableEndpointRouting = false) .AddNewtonsoftJson();

that means Endpoint Routing is disabled by default on ASP.NET Core 3.0 Angular application. My question is why it is disabled? Does ASP.NET Core 3.0 preview 4 SPA not support Endpoint Routing yet?

Just like this only
services.AddMvc(option => option.EnableEndpointRouting = false)
that worked for me!! :)

I see the 3.0 Spa templates using endpoint routing: https://github.com/aspnet/AspNetCore/blob/master/src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs#L105

Are you sure you've updated correctly?

@rynowak Yes! I see endpoint routing has been added in ASP.NET Core 3.0 GA release. If you want you can close the issue with marking as fixed!

Thank you.

like this only. i worked for me.
services.AddMvc(option => option.EnableEndpointRouting = false) ;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TanvirArjel picture TanvirArjel  路  3Comments

rbanks54 picture rbanks54  路  3Comments

ermithun picture ermithun  路  3Comments

guardrex picture guardrex  路  3Comments

githubgitgit picture githubgitgit  路  3Comments