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" ...
随机推荐
- String类型根据逗号分隔转为list
String ids = pd.getString("IDS");//从pd里取出字符串 List idList = Arrays.asList(ids.split(", ...
- "转成"
在java中这样转 StringEscapeUtils.unescapeHtml(soapResponseData); 在js中这样转 str.replace(""",& ...
- php 时间 数组替换
//随机数和时间//随机数生产器//echo rand();//echo "<br>";//生成某个范围的随机数//echo rand(0,10);//echo &qu ...
- left join 与left outer join的区别
joinn 语句有三种:inner join, left outer join 和 right outer join都可以简写,分别为join,left join,right join.
- POJ 1386 单词接龙问题
题目大意: 给一堆字母,让它们进行接龙,要头对尾能够接的上,问有没有一种方法让所有成语都完成接龙 这道题实际上是在考虑是否存在一条欧拉通路,每个单词产生一条有向线段,由第一个字母指向最后一个字母 这道 ...
- java web 项目常用框架
java框架实在是太多了,网上一搜索一大箩筐,根本就了解不到什么. 我还是以我的经验来说一下j2ee的框架. 1.首先力推struts2框架,这是最经典的框架(可以说没有“之一”).可以帮你快速搭建出 ...
- 2016 Multi-University Training Contest 1 solutions BY HIT
首先向大家表示抱歉,因为这套题是去年出的,中间间隔时间太长,今年又临时准备仓促, 所以部分题目出现了一些问题,非常抱歉. Abandoned country 首先注意到任意两条边的边权是不一样的,由此 ...
- windows 下安装Apache httpd 只需三步
1.下载 Apache 官网地址:http://httpd.apache.org/docs/current/platform/windows.html#down 找到这个, 看到这几个选项: Apac ...
- msp430项目编程30
msp430中项目---电压检测系统 1.SVS工作原理 2.电路工作原理 3.代码(显示部分) 4.代码(功能实现) 5.项目总结
- ACM常用模板整理
线段树单点修改区间查询 #include<stdio.h> #include<string.h> #include<algorithm> using namespa ...