How to bufferise the response from the action?

ⅰ亾dé卋堺 提交于 2019-12-25 02:34:46

问题


How can I send some part of the web response without waiting the all rendering process finish? I prefer do that in an Action.

I used to use Response.Buffer = false; in .net 2.0 but now with MVC 3 I don't know how to do that.


回答1:


You can potentially use an Action Filter to set the Buffer property.

public class BufferActionFilter: ActionFilterAttribute
{
          public override void OnActionExecuting(ActionExecutingContext filterContext)
          {
               filterContext.HttpContext.Response.Buffer = true;       
          }
}

PS: I have not checked if this works though.



来源:https://stackoverflow.com/questions/13014261/how-to-bufferise-the-response-from-the-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!