Response.Write() 和 Response.Output.Write() 有什么区别?
Response.Write()
和 Response.Output.Write()
之间有什么区别?
What’s the difference between Response.Write()
and Response.Output.Write()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它们都使用
TextWriter
写入输出流(不是直接写入 Stream),但是使用HttpContext.Response.Output.Write
提供更多重载(Framework 2.0 中为 17,包括格式化选项)比HttpContext.Response.Write
(只有 4 个没有格式化选项)。HttpResponse
类型不允许直接“设置”访问其输出流。They both write to the output stream using a
TextWriter
(not directly to a Stream), however usingHttpContext.Response.Output.Write
offers more overloads (17 in Framework 2.0, including formatting options) thanHttpContext.Response.Write
(only 4 with no formatting options).The
HttpResponse
type does not allow direct 'set' access to its output stream.真的没什么。
但。
Response.Write
获取Response.Output
属性中的流。 您可以设置另一个输出流,这样就可以写入文件或其他疯狂的东西,而不是写回客户端。 这就是关系。Nothing really.
But.
Response.Write
takes the stream in theResponse.Output
property. You could set another Output stream, and in that way instead of writing back to the client, maybe write to a file or something crazy. So thats there relation.Response.Output.Write()
:用于显示任何类型的数据,如 int、date、string 等。即显示格式化的输出。Response.Write()
:仅显示字符串类型的数据,即无法显示格式化的output()。要显示 Response.Write() 的格式化输出,您可以编写:
Response.Output.Write()
: It is used to display any type of data like int, date, string etc. i.e. It displays the formatted output.Response.Write()
: To display only string type of data i.e. It's can't display formatted output().To display formatted output from
Response.Write()
you can write:尽管 Response.Output.Write() 提供了更多重载,允许您传递不同的参数,但实际上没有区别。 Scott Hansleman 深入介绍。
There is effectively no difference, although
Response.Output.Write()
provides more overloads which can allow you to pass different parameters. Scott Hansleman covers it in depth.