我正在将一个大型.NET框架项目转换为一个.NET核心项目,我遇到了以下代码:
public class ContentStreamingResult : ActionResult {
private Action<Stream> _onExecuteAction;
public ContentStreamingResult(Action<Stream> onExecuteAction) {
_onExecuteAction = onExecuteAction;
}
public override void ExecuteResult(ControllerContext context) {
var httpContext = context.HttpContext;
httpContext.Response.BufferOutput = false;
_onExecuteAction(httpContext.Response.OutputStream);
}
}在BufferOutput核心中的HttpResponse类上没有任何.NET属性。
什么是HttpResponseBase.BufferOutput内核2中的ASP.NET属性?
发布于 2018-09-28 01:42:10
为了在Asp.Net核心中启用UseResponseBuffering,您可以在Startup中使用UseResponseBuffering中间件,如下所示:
app.UseResponseBuffering();应用Buffering Middleware之后,如果要禁用特定请求的缓冲区,可以尝试下面的代码:
var bufferingFeature = httpContext.Features.Get<IHttpBufferingFeature>();
bufferingFeature?.DisableResponseBuffering();发布于 2021-10-18 07:56:44
您可以使用IHttpResponseBodyFeature作为响应缓冲区,也可以使用IHttpRequestBodyFeature作为请求缓冲区。
httpContext.Features.Get<IHttpResponseBodyFeature>().DisableBuffering()https://stackoverflow.com/questions/52542603
复制相似问题