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
A number of APIs in .NET Core are async aware and probably should have been in .NET Framework. However, when adapting the behavior of core behind the APIs framework had ends up with a number of sync over async patterns. We should provide a way forward here that will guide people to using async.
Motivation and goals
We should provide async methods that end up calling into async pathways on .NET Core. Currently, this is handled either by invoking required async pathways in middleware or by calling GetAwaiter().GetResult().
In scope
This would ideally provide APIs that users on framework, core, and standard could all use. Depending on where things run, it would either be true async (i.e. on ASP.NET Core) or just return a completed task (i.e. on ASP.NET Framework).
Initial APIs identified:
HttpRequest.InputStream
HttpResponse.End()
HttpResponse.TransmitFile
HttpResponse.SendFile
probably some more (especially those that rely on any of these APIs).
Out of scope
No plans to make ASP.NET Framework more async aware
Risks / unknowns
Developers may think this is making ASP.NET Framework async aware
A number of these APIs are also exposed on the *Base and *Wrapper types. Would need to identify how to handle those
Since we're type forwarding to System.Web.dll on framework, we will probably want to provide any async functionality as extension methods that would forward to the non-async on framework while using actual async behavior on ASP.NET Core
The text was updated successfully, but these errors were encountered:
Since this isn't planned: when the interfaces like IHttpResponseEndFeature are publicly available (which been suggested for mocking #332 (comment) and has been added to the milestone 1.3) we could make our own extension methods:
usingSystem.Threading.Tasks;usingHttpResponse=System.Web.HttpResponse;
#if NET8_0_OR_GREATER// ASP.NET Core implementationusingSystem.Runtime.CompilerServices;usingMicrosoft.AspNetCore.Http.Features;usingHttpResponseCore=Microsoft.AspNetCore.Http.HttpResponse;namespaceSystemWeb{publicstaticclassHttpResponseExtensions{[UnsafeAccessor(UnsafeAccessorKind.Field,Name="_response")]privatestaticexternHttpResponseCoreGetResponse(HttpResponse@this);publicstaticTaskEndAsync(thisHttpResponse@this)=>GetResponse(@this).HttpContext.Features.GetRequiredFeature<IHttpResponseEndFeature>().EndAsync();}}
#else
// ASP.NET implementationnamespaceSystemWeb{publicstaticclassHttpResponseExtensions{publicstaticTaskEndAsync(thisHttpResponse@this){@this.End();returnTask.CompletedTask;}}}
#endif
Summary
A number of APIs in .NET Core are async aware and probably should have been in .NET Framework. However, when adapting the behavior of core behind the APIs framework had ends up with a number of sync over async patterns. We should provide a way forward here that will guide people to using async.
Motivation and goals
We should provide async methods that end up calling into async pathways on .NET Core. Currently, this is handled either by invoking required async pathways in middleware or by calling
GetAwaiter().GetResult()
.In scope
This would ideally provide APIs that users on framework, core, and standard could all use. Depending on where things run, it would either be true async (i.e. on ASP.NET Core) or just return a completed task (i.e. on ASP.NET Framework).
Initial APIs identified:
HttpRequest.InputStream
HttpResponse.End()
HttpResponse.TransmitFile
HttpResponse.SendFile
probably some more (especially those that rely on any of these APIs).
Out of scope
Risks / unknowns
Examples
Currently:
after:
Design considerations
*Base
and*Wrapper
types. Would need to identify how to handle thoseSystem.Web.dll
on framework, we will probably want to provide any async functionality as extension methods that would forward to the non-async on framework while using actual async behavior on ASP.NET CoreThe text was updated successfully, but these errors were encountered: