HttpContext.Current.Response和Page.Response有什么区别? [英] What is the difference between HttpContext.Current.Response and Page.Response?

查看:419
本文介绍了HttpContext.Current.Response和Page.Response有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对一组安全页面上的缓存问题进行故障排除,并且已经意识到需要针对所有响应修改标头。当我整理一个解决方案时,我想知道HttpContext.Current.Response和Page.Response之间的区别,以及何时应该在应用程序中使用每个对象。

I'm troubleshooting a caching issue on a set of secured pages and have realized that the Header needs to be modified for all Responses. As I put together a solution, I want to know the difference between HttpContext.Current.Response and Page.Response and when each object should be used in an app.

谢谢。

推荐答案

Page.Response 只是到HTTPContext的映射你在HTML页面的上下文中。

Page.Response is simply a mapping to the HTTPContext when you are within the context of an HTML page.

HttpContext.Current.Response 只是让你到达当前上下文,当您不在页面中时。让您从响应请求的实际页面以外的位置访问上下文。

HttpContext.Current.Response simply allows you to get to the current context, when you are not in a page. ALlowing you to access the context from locations other than the actual page responding to the request.

至于何时使用每个?好吧,如果你愿意的话,你可以在任何地方使用HttpContext.Current.Response,但通常人们会在页面/用户控件上使用Page.Response。

As for when to use each? Well you "Can" use HttpContext.Current.Response everywhere if you want, but typically people will use Page.Response when on a page/usercontrol.

这篇关于HttpContext.Current.Response和Page.Response有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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