public static HttpContext Current
    {
      get
      {
        return ContextBase.Current as HttpContext;
      }
      set
      {
        ContextBase.Current = (object) value;
      }
    }

 

 internal class ContextBase
  {
    internal static object Current
    {
      get
      {
        return CallContext.HostContext;
      }
      [SecurityPermission(SecurityAction.Demand, Unrestricted = true)] set
      {
        CallContext.HostContext = value;
      }
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    public ContextBase()
    {
    }

    internal static object SwitchContext(object newContext)
    {
      object hostContext = CallContext.HostContext;
      if (hostContext != newContext)
        CallContext.HostContext = newContext;
      return hostContext;
    }
  }

 

 public static Object HostContext
        {
            [System.Security.SecurityCritical]  // auto-generated
            get
            {
                Object hC;
                IllogicalCallContext ilcc = Thread.CurrentThread.GetIllogicalCallContext();
                hC = ilcc.HostContext;
                if (hC == null)
                {
                    LogicalCallContext lcc = GetLogicalCallContext();
                    hC = lcc.HostContext;
                }
                return hC;
            }
            [System.Security.SecurityCritical]  // auto-generated_required
            set
            {
                if (value is ILogicalThreadAffinative)
                {
                    IllogicalCallContext ilcc = Thread.CurrentThread.GetIllogicalCallContext();
                    ilcc.HostContext = null;
                    LogicalCallContext lcc = GetLogicalCallContext();
                    lcc.HostContext = value;
                }
                else
                {
                    LogicalCallContext lcc = GetLogicalCallContext();
                    lcc.HostContext = null;
                    IllogicalCallContext ilcc = Thread.CurrentThread.GetIllogicalCallContext();
                    ilcc.HostContext = value;
                }
            }
        } 

 

        internal IllogicalCallContext GetIllogicalCallContext()
        {
            return ExecutionContext.IllogicalCallContext;
        } 

System.Web.HttpContext.Current 跟踪分析的更多相关文章

  1. System.Web.HttpContext.Current.Session为NULL解决方法

    http://www.cnblogs.com/tianguook/archive/2010/09/27/1836988.html 自定义 HTTP 处理程序,从IHttpHandler继承,在写Sys ...

  2. 为什么获取的System.Web.HttpContext.Current值为null,HttpContext对象为null时如何获取程序(站点)的根目录

    ASP.NET提供了静态属性System.Web.HttpContext.Current,因此获取HttpContext对象就非常方便了.也正是因为这个原因,所以我们经常能见到直接访问System.W ...

  3. HttpContext为null new HttpContextWrapper(System.Web.HttpContext.Current)

    HttpContext = (context == null ? new HttpContextWrapper(System.Web.HttpContext.Current) : context);

  4. System.Web.HttpContext.Current.Server.MapPath("~/upload/SH") 未将对象引用设置为实例对象

    做项目的时候,System.Web.HttpContext.Current.Server.MapPath("~/upload/SH")   获取路径本来这个方法用的好好的 因为需要 ...

  5. System.Web.HttpContext.Current.Session获取值出错

    在自定义类库CS文件里使用System.Web.HttpContext.Current.Session获取Session时提示错误:未将对象引用设置到对象的实例. 一般情况下通过这种方式获取Sessi ...

  6. System.Web.HttpContext.Current.Session为NULL值的问题?

    自定义 HTTP 处理程序,从IHttpHandler继承,在写System.Web.HttpContext.Current.Session["Value"]的时 候,没有问题,但 ...

  7. .NET System.Web.HttpContext.Current.Request报索引超出数组界限。

    移动端使用Dio发送 FormData, 请求类型 multipart/form-data, FormData内可以一个或多个包含文件时. 请求接口时获取上传的fomdata数据使用 System.W ...

  8. System.Web.HttpContext.Current.Request用法

    public static void SetRegisterSource() { if (System.Web.HttpContext.Current.Request["website&qu ...

  9. 慎用System.Web.HttpContext.Current

    每当控制流离开页面派生的Web表单上的代码的时候,HttpContext类的静态属性Current可能是有用的. 使用这个属性,我们可以获取当前请求(Request),响应(Response),会话( ...

随机推荐

  1. postfix 邮件备份方法

    postfix 邮件备份方法: postfix的bcc(密送)功能可以根据条件,将所有经过postfix队列的邮件根据规则密送到指定的邮箱. postfix带有三个bcc参数: ①.always_bc ...

  2. PHP 上传图片和安全处理

    上传图片 public function images() { $data = $_FILES['file']; switch($data['type']) { case 'image/jpeg': ...

  3. 解决在MainPage中,点击实体返回按键不能退出的问题

    开发Windows Phone应用程序的时候,我在其它页面有写过这样的代码: private void btCancel_Click(object sender, EventArgs e) { Nav ...

  4. magento关于站点搬家,换空间

    1,先把原来空间的文件全部压缩后(有些不要的就不要压缩)下载下来,然后传到新空间去,注意下载下来后核对一下是否大小一样,建议使用ftp工具下载, 2,同样把原来空间的数据库打包下来,再在新空间创建一个 ...

  5. 第三个Sprint完结工作 用场景来规划测试工作.

    一.根据用户使用场景测试: 1.流程 典型群体 群体 张小明 年龄 7-12岁 职业 小学生 收入 压岁钱还有零花钱 能力 看一些简单的数,做一些相对简单的事 爱好 玩游戏 典型场景 张小明平时喜欢玩 ...

  6. Fix VNC Desktop Sharing on Ubuntu Desktop 14.04

    Solution 1 sudo apt-get -y install dconf-tools dconf write /org/gnome/desktop/remote-access/require- ...

  7. 《More Effective C++ 》笔记

    条款10 防止构造函数里的资源泄露 条款20 协助编译器实现返回值优化 条款22 考虑使用op=来取代单独的op运算符 条款26 限制类对象的个数 条款27 要求或禁止对象分配在堆上

  8. 传智springMVC笔记

    springmvc 第一天 springmvc的基础知识 课程安排: 第一天:springmvc的基础知识 什么是springmvc? springmvc框架原理(掌握) 前端控制器.处理器映射器.处 ...

  9. getDefinitionByName getDefinition 区别

    一闺密用flash开发IOS应用是遇到一个问题,她把声音资源放到swf里,然后load到主程序中使用,但是ios提示不支持这个swf,我在想是不是因为有声音的原因 于是我让她换种做法,不用swf,用s ...

  10. Python编程感悟

    从今年起开始学习python,最开始是听得MIT的那门公开课,然后又看了一本入门的书籍.但是总是没有觉得python很好用.可能的原因现在想起来是:IDE始终找不到顺手的,另外R用得太舒服了- any ...