Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TanvirArjel opened this issue Apr 19, 2019 · 7 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Done This issue has been fixed
Milestone

Comments

@TanvirArjel
Copy link
Contributor

TanvirArjel commented Apr 19, 2019

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?

@davidfowl
Copy link
Member

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/

@rynowak
Copy link
Member

rynowak commented Apr 19, 2019

Takea a look at this as well: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-2.2&tabs=visual-studio#update-routing-startup-code

@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Apr 19, 2019
@blowdart blowdart added this to the Discussions milestone Apr 19, 2019
@TanvirArjel
Copy link
Contributor Author

@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?

@thanhtai9606
Copy link

@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!! :)

@rynowak
Copy link
Member

rynowak commented Oct 3, 2019

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?

@TanvirArjel
Copy link
Contributor Author

TanvirArjel commented Oct 3, 2019

@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.

@rynowak rynowak closed this as completed Oct 3, 2019
@rynowak rynowak added the Done This issue has been fixed label Oct 3, 2019
d97rew pushed a commit to d97rew/Web-Application that referenced this issue Oct 15, 2019
fix   services.AddMvc
to:
services.AddMvc(option => option.EnableEndpointRouting = false);
dotnet/aspnetcore#9542
tadic-luka pushed a commit to tadic-luka/Electron.NET that referenced this issue Oct 22, 2019
EnableEndpointRouting should be set to false. Otherwise people will get error: 
Application startup exception: System.InvalidOperationException: Endpoint Routing does not support 'IApplicationBuilder.UseMvc(...)'. To use 'IApplicationBuilder.UseMvc' set 'MvcOptions.EnableEndpointRouting = false' inside 'ConfigureServices(...). 
The solution is even proposed in stack trace.
Issue was opened on dotnet/aspnetcore#9542 and it is explained there what should be done.
@riadh11
Copy link

riadh11 commented Oct 23, 2019

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

TomPallister pushed a commit to ThreeMammals/Ocelot that referenced this issue Oct 28, 2019
* feat: update to asp.net core 3.0 preview 9

* fix :  AspDotNetLogger unittest

* feat:  update generic host  and  useMvc

1、Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing dotnet/aspnetcore#9542
2、 use IHost and IHostBuilder

* feat : update .net core 3.0 rc1

* eureka extension

* fixed logger formatter error

* fixed synchronous operations are disallowed of ReadToEnd method

* fix log tests

* Flush method of FakeStream should do nothing

* Update ContentTests.cs

* Fixed ws tests

* feat: delelte comment code

* feat: update .net core 3.0 RTM

* Update OcelotBuilderTests.cs

* Update .travis.yml

mono 6.0.0 and dotnet 3.0.100

* Update Ocelot.IntegrationTests.csproj

update Microsoft.Data.SQLite 3.0.0

* Update .travis.yml

* feat: remove FrameworkReference

1、 remove FrameworkReference
2、 update package

* add appveyor configuration to use version of VS2019 with dotnet core 3 sdk support

* update obsoleted SetCollectionValidator method

* Swap out OpenCover for Coverlet

* Bump Cake to 0.35.0

* Downgrade coveralls.net to 0.7.0
Fix disposing of PollConsul instance

* Remove environment specific path separator

* Do not return ReportGenerator on Mac/Linux

* Remove direct dependency on IInternalConfiguration

* Fix ordering of variable assignment

* Fix broken tests

* Fix acceptance tests for Consul
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Done This issue has been fixed
Projects
None yet
Development

No branches or pull requests

7 participants