Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
HttpContext.Current和有什么区别System.Web.UI.Page.Context吗?方法的thenHttpContext参数之间有区别吗?ProcesRequestIHttpHandler
HttpContext.Current
System.Web.UI.Page.Context
HttpContext
ProcesRequest
IHttpHandler
如果没有区别,为什么不总是使用HttpContext.Current?
有没有最好不要使用的情况HttpContext.Current?
如果您有选择,最好避免使用任何类型的全局变量/属性,而是使用更多本地版本,以使代码更具自记录性(显式依赖项更容易看到)和可测试(更容易通过模拟/自定义对象而不是尝试设置潜在的不可写的全局属性)。
如果HttpRequest您提到的所有方式都会给您相同的对象。不同之处在于,如果您将一个传递给您的方法,那么与使用HttpContext.Current.
HttpRequest