You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Help Needed] Endpoint Routing does not support 'IApplicationBuilder.UseMvc(...)'. To use 'IApplicationBuilder.UseMvc' set 'MvcOptions.EnableEndpointRouting = false' inside 'ConfigureServices(...).
#795
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.
I was following the step-by-step guide, but I'm stuck in the method Configure in Startup.cs.
When app.UseJsonApi(); is called the following error is thrown:
System.InvalidOperationException
HResult=0x80131509
Message=Endpoint Routing does not support 'IApplicationBuilder.UseMvc(...)'. To use 'IApplicationBuilder.UseMvc' set 'MvcOptions.EnableEndpointRouting = false' inside 'ConfigureServices(...).
Source=Microsoft.AspNetCore.Mvc.Core
StackTrace:
at Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(IApplicationBuilder app, Action`1 configureRoutes)
at Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(IApplicationBuilder app)
at JsonApiDotNetCore.Extensions.IApplicationBuilderExtensions.UseJsonApi(IApplicationBuilder app, Boolean useMvc)
at SIGN.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in Startup.cs:line 134
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__2(IApplicationBuilder app)
at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.<StartAsync>d__31.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__9.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at SIGN.Program.Main(String[] args) in Program.cs:line 16
This exception was originally thrown at this call stack:
Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(Microsoft.AspNetCore.Builder.IApplicationBuilder, System.Action<Microsoft.AspNetCore.Routing.IRouteBuilder>)
Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(Microsoft.AspNetCore.Builder.IApplicationBuilder)
JsonApiDotNetCore.Extensions.IApplicationBuilderExtensions.UseJsonApi(Microsoft.AspNetCore.Builder.IApplicationBuilder, bool)
SIGN.Startup.Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder, Microsoft.AspNetCore.Hosting.IWebHostEnvironment) in Startup.cs
System.Reflection.RuntimeMethodInfo.Invoke(object, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo)
Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(object, Microsoft.AspNetCore.Builder.IApplicationBuilder)
Microsoft.AspNetCore.Hosting.ConfigureBuilder.Build.AnonymousMethod__0(Microsoft.AspNetCore.Builder.IApplicationBuilder)
Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup.AnonymousMethod__2(Microsoft.AspNetCore.Builder.IApplicationBuilder)
Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.Configure.__MiddlewareFilterBuilder|0(Microsoft.AspNetCore.Builder.IApplicationBuilder)
...
[Call Stack Truncated]
I didn't find anything on the docs mentioning about the need to use MVC. Is this a limitation?
Here is the some relevant piece of code:
publicvoidConfigureServices(IServiceCollectionservices){services.AddDbContext<DatabaseContext>(options =>options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));services.AddJsonApi<DatabaseContext>();services.AddControllers();services.AddCors(options =>// some configuration);// some other config..........}publicvoidConfigure(IApplicationBuilderapp,IWebHostEnvironmentenv){if(env.IsDevelopment()){app.UseDeveloperExceptionPage();}app.UseHttpsRedirection();app.UseRouting();app.UseJsonApi();// error is thrown in this line.app.UseCors("default");app.UseAuthentication();app.UseAuthorization();app.UseEndpoints(endpoints =>{endpoints.MapControllers().RequireAuthorization();});// some other config..........}
Any help would be appreciated.
Best regards.
Environment
JsonApiDotNetCore Version: 3.1.0
.Net Core Version: 3.1.101
The text was updated successfully, but these errors were encountered:
Besides that, the base constructor also has a different signature, notice that resourceService changed its position with loggerFactory.
Maybe the docs is outdated? I'm lost here.
Any help would be appreciated.
Thanks in advance.
There's a community attempt to get JADNC v3.x running on .NET Core 3.1 that may help.
Though I would recommend to use the latest v4 prerelease instead, because 3.x is very old and a lot has changed since then. Release plans for v4 are tracked at #693. The published documentation is generated from the master branch, which contains v4.
Speaking for myself: I joined this project at a time that v4 was already in development. So I have never used JADNC v3.x and have no interest in doing any work on it.
It looks like I hadn't paid attention in the Compatibility section in the readme. My bad, sorry.
I'll take your advice in consideration. Thanks.
Thank you even more for your personal advice.
Reproduce the issue
Fork it and reproduce the issue: Trying to use JADNC in a Web API with .net core 3.1. It's a very basic example.
Description
I was following the step-by-step guide, but I'm stuck in the method
Configure
inStartup.cs
.When
app.UseJsonApi();
is called the following error is thrown:I didn't find anything on the docs mentioning about the need to use MVC. Is this a limitation?
Here is the some relevant piece of code:
Any help would be appreciated.
Best regards.
Environment
The text was updated successfully, but these errors were encountered: