我正在将大型 .NET Framework 项目转换为 .NET Core 项目,并且遇到以下代码:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
.NET Core 中BufferOutput的HttpResponse类没有属性。
什么是HttpResponseBase.BufferOutputASP.NET Core 2中的属性?
要Buffering在 Asp.Net Core 中启用,您可以使用如下UseResponseBuffering中间件Startup:
app.UseResponseBuffering();
Run Code Online (Sandbox Code Playgroud)
应用后Buffering Middleware,如果您想禁用特定请求的缓冲区,您可以尝试以下代码:
var bufferingFeature = httpContext.Features.Get<IHttpBufferingFeature>();
bufferingFeature?.DisableResponseBuffering();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2049 次 |
| 最近记录: |