Difference between HttpContext.Request and Request
https://stackoverflow.com/questions/5547989/difference-between-httpcontext-request-and-request
Well:
HttpContext.Current
is a static property returning the currentHttpContext
for the threadHttpContext.Request
is an instance property returning theHttpRequest
for theHttpContext
you call it onPage.Request
is an instance property inPage
, returning theRequest
associated with the page you call it on (typically implicitlythis
)
So HttpContext.Current.Request
will use both of the first two properties in order to get the request associated with the current thread. If you're in the thread dealing with a request, that's going to be the same as the Page.Request
within the relevant page which is being rendered.
However, if your rendering kicks off a different thread, the code running in the other thread can still get at the Request
via Page.Request
(because it's just a normal property) but there'll be no HttpContext
associated with the thread - so HttpContext.Current.Request
wouldn't work.
EDIT: To respond to the edited question, in global.asax the Request
property refers to HttpApplication.Request
, and is probably the best approach to use. HttpContext.Request
won't work, because that's trying to access a static property as if it were an instance property. HttpContext.Current.Request
should work, assuming the context has been associated with the thread by that point.
Difference between HttpContext.Request and Request的更多相关文章
- String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
- C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法
C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法? Request.params , Request ...
- basePath = request.getScheme()+"://"+request.getServerName()+":"+r
basePath = request.getScheme()+"://"+request.getServerName()+":"+r (2014-06-30 1 ...
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+pat----------<base>元素有关
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. ...
- request.get request.GET……
发现他们是不同的. 报错: AttributeError at /add/ 'WSGIRequest' object has no attribute 'get' Request Method: GE ...
- 客户端的数据来源:QueryString, Form, Cookie Request[]与Request.Params[]
在ASP.NET编程中,有三个比较常见的来自于客户端的数据来源:QueryString, Form, Cookie . 我们可以在HttpRequest中访问这三大对象. QueryString: 获 ...
- JSP之项目路径问题(${pageContext.request.contextPath},<%=request.getContextPath()%>以及绝对路径获取)
本随笔这是作为一个记录使用,以备后查.项目完成之后本地部署OK,本地Linux部署OK,都可以正常的访问,可是当我把它部署到服务器上面的时候,首页可以正常访问,可是当发出请求的时候却报错误了,说找不到 ...
- 安卓开发笔记(十六):'Request(okhttp3.Request.Builder)' has private access in 'okhttp3.Request
当出现了'Request(okhttp3.Request.Builder)' has private access in 'okhttp3.Request的错误的时候,实际上是我们在写代码的时候少打了 ...
- <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
- [转载]Request、Request.Form和Request.QueryString的区别
Request.Request.Form和Request.QueryString的区别 request本身是一个系统的静态对象,本身也可以作为数组调用,比如request("abc" ...
随机推荐
- Hyperledger Fabric创建通道抛错Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied解决方案
安装Hyperledger Fabric,服务整个都跑起来了,但是抛了一个错,Error: got unexpected status: FORBIDDEN -- Failed to reach im ...
- Go 方法和接收者
package main import ( "fmt" ) //面向对象 //go仅支持封装,不支持继承和多态 //go语言中没有class,只要struct //不论地址还是结构 ...
- bzoj3514 Codechef MARCH14 GERALD07加强版 lct预处理+主席树
Codechef MARCH14 GERALD07加强版 Time Limit: 60 Sec Memory Limit: 256 MBSubmit: 1951 Solved: 746[Submi ...
- Can you answer these queries(spoj 1043)
题意:多次查询区间最长连续字段和 /* 用线段树维护区间最长子段和,最长左子段和,最长右子段和. */ #include<cstdio> #include<iostream> ...
- RQNOJ273 马棚问题
题目描述 每天,小明和他的马外出,然后他们一边跑一边玩耍.当他们结束的时候,必须带所有的马返回马棚,小明有K个马棚.他把他的马排成一排然后跟随它走向马棚,因为他们非常疲劳,小明不想让他的马做过多的移动 ...
- Android服务Service
安卓Service服务 一 Service简介 Service是运行在后台的,没有界面的,用来处理耗时比较长的.Service不是一个单独的进程,也不是一个单独的线程. Service有两种类型 ...
- APP后端处理表情的一些技巧
app应用中文字夹带表情是个很常见的现象.甚至一些40多岁的大叔级用户,也喜欢在自己的昵称中夹带表情,在产品运营后发现这个现象,彻底颠覆了我的世界观. 在后台处理表情的时间,我遇到过下面3个问题: 1 ...
- 洛谷——P1262 间谍网络
P1262 间谍网络 题目描述 由于外国间谍的大量渗入,国家安全正处于高度的危机之中.如果A间谍手中掌握着关于B间谍的犯罪证据,则称A可以揭发B.有些间谍收受贿赂,只要给他们一定数量的美元,他们就愿意 ...
- topcoder 650 srm
500 遇到这种构造题 就给跪了 比赛的时候想很多方法 DP,贪心,模拟 发现越写越烦琐.看到别人出这么快,肯定又是奇葩思路. 后来居然想到 2^50的暴力 +剪枝 不过暴力肯定卡你 IDEA: 只要 ...
- 简单使用SOCKET,TCP,UDP模式之间的通信
TCP(Transmission Control Protocol 传输控制协议)是一种面向连接的.可靠的.基于字节流的传输层通信协议,由IETF的RFC 793定义.在简化的计算机网络OSI模型中, ...