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

Calling Request.EnableRewind throw on 3.0.0-preview7 #12505

Closed
bruno-garcia opened this issue Jul 24, 2019 · 8 comments
Closed

Calling Request.EnableRewind throw on 3.0.0-preview7 #12505

bruno-garcia opened this issue Jul 24, 2019 · 8 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Comments

@bruno-garcia
Copy link
Member

bruno-garcia commented Jul 24, 2019

An ASP.NET Core 3 app calling out to a library which depends on Microsoft.AspNetCore.Hosting 2.x and access HttpContext.Request.EnableRewind() throws an exception.

To Reproduce

I have a repro here: https://github.com/bruno-garcia/aspnetcore3-hosting2.x-enable-rewind-throws

Steps to reproduce the behavior:

  1. .NET SDK 3.0.100-preview7-012821.
  2. Using this version of ASP.NET Core '3.0.0-preview7.19365.7 '
  3. Create a new class library targeting netstandard2.0
  4. Add dependency to Microsoft.AspNetCore.Hosting version 2.2
  5. Call HttpContext.Request.EnableRewind() in it.
  6. Use the library from the ASP.NET Core 3 app

Expected behavior

Request buffering happens

Error:

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLOG3BFKK5BS", Request id "0HLOG3BFKK5BS:00000001": An unhandled exception was thrown by the application.
System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Http.Internal.BufferingHelper' from assembly 'Microsoft.AspNetCore.Http, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
   at Class1.<>c.<<EnableRewind>b__0_0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Class1.<>c.<EnableRewind>b__0_0(HttpContext context, Func`1 next)
   at Microsoft.AspNetCore.Builder.UseExtensions.<>c__DisplayClass0_1.<Use>b__1(HttpContext context)
   at Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Hosting.HostingApplication.ProcessRequestAsync(Context context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Raised here: getsentry/sentry-dotnet#249

In all fairness the extension method in question is under Microsoft.AspNetCore.Http.Internal and even on 2.1 it was also available EnableBuffering. I've replaced the two in the library and it's working properly.

@jkotalik
Copy link
Contributor

@davidfowl is this a scenario we still try to support where we have different dependencies to ASP.NET Core?

@pranavkm
Copy link
Contributor

/cc @Tratcher. Does this need a breaking change announcement?

@davidfowl
Copy link
Member

This is part of the pubternal move to internal. We haven’t written the uber announcement for that as yet.

@Tratcher
Copy link
Member

@WellspringCS That's related only in that there's a dependency mismatch.

@WellspringCS
Copy link

OK, so likely to go away when they release an updated version, I take it.

@analogrelay
Copy link
Contributor

Closing as this should be fixed when referencing the latest versions.

@sc1994
Copy link

sc1994 commented Aug 19, 2019

This problem persists after version 3.0.100-preview8-013656 is specified, with the same error.
Do I need to do more?

@runxc1
Copy link

runxc1 commented Aug 22, 2019

@sc1994 if I read this correctly you would need to change any calls to EnableRewind to EnableBuffering as shown in the the pull request that sentry committed to fix this in their code. getsentry/sentry-dotnet@520bb78

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests