Skip to content

"A request container already exists on the request" exception for batch requests  #2068

@ud09

Description

@ud09

When I used v7.3.0, I got the error at #2009 when the response is returning
Then I tried the latest nightly build 7.4.0-nightly202002252317 that seems to include a fix for that.
Now I get the below error when the request is coming:
!!! No errors if I don't use endpoint routing !!!

System.Exception
  HResult=0x80131500
  Message=System.InvalidOperationException: A request container already exists on the request.
   at Microsoft.AspNet.OData.Extensions.HttpRequestExtensions.CreateRequestContainer(HttpRequest request, String routeName)
   at Microsoft.AspNet.OData.Batch.DefaultODataBatchHandler.ParseBatchRequestsAsync(HttpContext context)
   at Microsoft.AspNet.OData.Batch.DefaultODataBatchHandler.ProcessBatchAsync(HttpContext context, RequestDelegate nextHandler)
   at Microsoft.AspNet.OData.Batch.ODataBatchMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS

Content-Type: multipart/mixed; boundary=batch_7f5b7766-597d-4546-bc0a-f214f9a4ca69
Host: localhost:9802
Content-Length: 700
session-guid: 7a90b3bb-664e-4285-b0dc-c3d9065a7ed2
OData-Version: 4.0

Assemblies affected

microsoft.aspnetcore.odata 7.4.0-nightly202002252317

Reproduce steps

My startup configuration is

	if (env.IsDevelopment())
	{
		app.UseDeveloperExceptionPage();
	}

	app.UseRouting();

	app.UseAuthentication();

	app.UseAuthorization();

	app.UseODataBatching();

	app.UseEndpoints(endpoints =>
	{
		endpoints.Select().Expand().Filter().OrderBy().MaxTop(100).Count();
		endpoints.MapODataRoute("odata", "", GetEdmModel(), new DefaultODataBatchHandler());
	});

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions