日期:2014-05-17  浏览次数:20423 次

关于 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 判断。具体的你自己看吧。