我重载了OnPreInit,然后在操作中调用了Dispose方法,但是我发现还会接着去调用各个控件的Init方法和页面的Page_Load方法。
请问有什么办法能提前结束页面的生命周期?

解决方案 »

  1.   

    不是很明白,给你个连接看一下吧!
    http://www.cnblogs.com/tianyue3107/archive/2009/04/21/1440278.html
      

  2.   

    直接在事件中写return;……就不会继续执行了……
      

  3.   


    protected void Page_PreInit(object sender, EventArgs e)
        {
            Page.Dispose();        
        }
    经过调试……不会继续执行了……
      

  4.   

    写个httphandler吧,额外判断在handler里做,不合要求直接抛空页面或错误页面,否则继续执行。
      

  5.   


        public class AspxHandleFactory : IHttpHandlerFactory, System.Web.SessionState.IRequiresSessionState
        {        #region IHttpHandlerFactory 成员        public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
            {
                if (符合额外检查要求)
                {
                    return System.Web.UI.PageParser.GetCompiledPageInstance(url, pathTranslated, context);//继续传个原本的aspx页面处理
                }
                else
                {//否则转到错误页。
                    string filepath = "~/AccessDenial.aspx";
                    if (url.ToLower().Contains("popwindow.aspx"))
                         filepath = "~/AccessDenial2.aspx";
                    return System.Web.UI.PageParser.GetCompiledPageInstance(filepath, context.Server.MapPath(filepath), context);
                }        }        void IHttpHandlerFactory.ReleaseHandler(IHttpHandler handler)
            {        }        #endregion    }