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. 团队开发——冲刺1.a

    冲刺阶段一(第一天) 1.今天准备做什么? 在了解C#的基础上,深入熟悉Windows窗体应用程序,熟练掌握基本功能. 2.明天做什么:简单设计界面.

  2. javascript笔记2-引用类型

    引用类型是一种数据结构,用于将数据和功能组织在一起.它描述的是一类对象所具有的属性和方法.Object是一个基础类型,Array是数组类型,Date是日期类型,RegExp是正则表达式类型,等. Ob ...

  3. VBS_DO...Loop

    循环用于重复执行一组语句.循环可分为三类:一类在条件变为 False 之前重复执行语句,一类在条件变为 True 之前重复执行语句,另一类按照指定的次数重复执行语句. 在 VBScript 中可使用下 ...

  4. ModelFirst的CRUD

    创建实体:

  5. WinFrm窗体的传值方式

    比较简单的方法: 一:1.定义两个窗体 2.在父窗体中加入子窗体的属性 public ChildFrm ChildFrm { get; set; } 3.加载的时候: private void Par ...

  6. Cinemagraph

    方法一:PS 如果动作太复杂帧数太多的话,处理起来相对复杂 方法二:iPhone App 参考阅读:http://socialbeta.com/t/cinemagraph-marketing-guid ...

  7. Application,Session,Cookie,ViewState和Cache区别

    在ASP.NET中,有很多种保存信息的内置对象,如:Application,Session,Cookie,ViewState和Cache等.下面分别介绍它们的用法和区别. 方法 信息量大小 作用域和保 ...

  8. nginx+c+cgi开发

    http://blog.csdn.net/marising/article/details/3932938 1.Nginx 1.1.安装 Nginx 的中文维基 http://wiki.codemon ...

  9. navicat MySQL 只有1000条记录

    /*************************************************************************** * navicat MySQL 只有1000条 ...

  10. Git命令整理

    说在前面: 刚开始在实习时接触git,是用git可视化工具,但是仅限于克隆库.切换分支.抓取和推送,对于其中的原理不甚了解.看了廖雪峰老师Git教程,获益颇丰.特别要感谢我工作中的同事,是他强烈建议我 ...