当前位置: 代码迷 >> ASP.NET >> 关于 asp.net 的 httpApplication 对象 、解决办法
  详细解决方案

关于 asp.net 的 httpApplication 对象 、解决办法

热度:1255   发布时间:2013-02-25 00:00:00.0
关于 asp.net 的 httpApplication 对象 、
 public void Init(HttpApplication context)
    {
         
        context.Context.Response;  //  获取当前 http响应的 httpResponse对象
        context.Response;         // 获取当前内部对应的对象。
        这两个有什么区别?
    
        
    }
------解决方案--------------------------------------------------------
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public HttpResponse Response
{
    get
    {
        HttpResponse response = null;
        if ((this._context != null) && !this._hideRequestResponse)
        {
            response = this._context.Response;
        }
        if (response == null)
        {
            throw new HttpException(SR.GetString("Response_not_available"));
        }
        return response;
    }
}

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public HttpContext Context
{
    get
    {
        if (this._context == null)
        {
            return this._initContext;
        }
        return this._context;
    }
}


可见context.Response 方法是对 context.Context.Response 的封装,多了 if 判断。具体的你自己看吧。
  相关解决方案