)到Response.End()和Response.Flush之间的差异( [英] Differences between Response.End() and Response.Flush()

查看:1830
本文介绍了)到Response.End()和Response.Flush之间的差异(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有code是这样的:

I have code like this:

context.HttpContext.Response.Clear();
            context.HttpContext.Response.Write(htmlString);              
            context.HttpContext.Response.End(); 

不过,页面加载时,我对他们有未闭合的HTML标签。当我更换到Response.End()与Response.Flush()它工作正常。
是什么到Response.End()和Response.Flush()?区别

But when pages are loaded I have unclosed html tag on them. When I replace Response.End() with Response.Flush() it works fine. What is difference between Response.End() and Response.Flush()?

推荐答案

Response.Flush

Response.Flush

强制所有当前缓冲的输出被发送到客户端。该
  冲洗方法可以请求处理过程中被多次调用。

Forces all currently buffered output to be sent to the client. The Flush method can be called multiple times during request processing.

到Response.End

Response.End

发送当前所有缓冲输出到客户端,停止执行
  该页面,并引发EndRequest事件。

Sends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event.

您应该尝试使用这个code,如果你不这样做的Response.Write后,页面上的任何处理,并要停止处理页面。

You should try using this code if you are not doing any processing on the page after Response.Write and want to stop processing the page.

    context.HttpContext.Response.Clear();
    context.HttpContext.Response.Write(htmlString);              
    context.HttpContext.Response.Flush(); // send all buffered output to client 
    context.HttpContext.Response.End(); // response.end would work fine now.

这篇关于)到Response.End()和Response.Flush之间的差异(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆