From: Argiris K. <be...@us...> - 2005-11-17 15:03:27
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23052/Core Modified Files: AjaxCallHelper.cs MagicAjax NET 2.0.csproj MagicAjax.csproj MagicAjaxModule.cs Log Message: Server.Transfer is working for 'NoStore' mode. Exceptions thrown during page processing are handled properly. Improvements for 'Storing' page modes (NoVerifyRenderingPage is not required) Fixed various problems that RBS_Control_Store was causing. Index: AjaxCallHelper.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/AjaxCallHelper.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AjaxCallHelper.cs 15 Nov 2005 12:55:11 -0000 1.3 --- AjaxCallHelper.cs 17 Nov 2005 15:03:16 -0000 1.4 *************** *** 87,90 **** --- 87,98 ---- /// <summary> + /// Determines whether the page is stored or recreated at each AjaxCall. + /// </summary> + public static bool IsPageNoStoreMode + { + get { return (MagicAjaxModule.Instance.Configuration.PageStore.Mode == Configuration.PageStoreMode.NoStore); } + } + + /// <summary> /// Gets the argument string the was sent by the client. /// </summary> *************** *** 167,170 **** --- 175,192 ---- #region Static Methods /// <summary> + /// Determines if the page is being processed during an AjaxCall. + /// </summary> + /// <remarks> + /// When the page is being processed for Server.Transfer, the Page's + /// IsPostBack property will be false. If this is the case IsAjaxCallForPage + /// will return false. + /// </remarks> + public static bool IsAjaxCallForPage (Page page) + { + return (AjaxCallHelper.IsAjaxCall && + ( (IsPageNoStoreMode && page.IsPostBack) || (!IsPageNoStoreMode && MagicAjaxModule.Instance.CurrentPageInfo.Page == page) ) ); + } + + /// <summary> /// Obtains a reference to a client-side script function that causes, when invoked, /// the control to raise an AjaxCall event to the server. This method also passes *************** *** 299,303 **** public static void Redirect(string url) { ! Response.Clear(); Write(String.Format("window.location.href=\"{0}\";\r\n", ResolveUrl(url))); End(); --- 321,325 ---- public static void Redirect(string url) { ! Init(); Write(String.Format("window.location.href=\"{0}\";\r\n", ResolveUrl(url))); End(); Index: MagicAjax NET 2.0.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax NET 2.0.csproj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MagicAjax NET 2.0.csproj 15 Nov 2005 14:07:31 -0000 1.5 --- MagicAjax NET 2.0.csproj 17 Nov 2005 15:03:16 -0000 1.6 *************** *** 124,133 **** <SubType>Code</SubType> </Compile> - <Compile Include="NoVerifyRenderingPage.cs"> - <SubType>ASPXCodeBehind</SubType> - </Compile> <Compile Include="StoredPageInfo.cs"> <SubType>Code</SubType> </Compile> <Compile Include="UI\AjaxControl.cs"> <SubType>Code</SubType> --- 124,133 ---- <SubType>Code</SubType> </Compile> <Compile Include="StoredPageInfo.cs"> <SubType>Code</SubType> </Compile> + <Compile Include="Util.cs"> + <SubType>Code</SubType> + </Compile> <Compile Include="UI\AjaxControl.cs"> <SubType>Code</SubType> Index: MagicAjax.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MagicAjax.csproj 14 Nov 2005 18:50:43 -0000 1.2 --- MagicAjax.csproj 17 Nov 2005 15:03:16 -0000 1.3 *************** *** 115,124 **** /> <File ! RelPath = "NoVerifyRenderingPage.cs" ! SubType = "ASPXCodeBehind" BuildAction = "Compile" /> <File ! RelPath = "StoredPageInfo.cs" SubType = "Code" BuildAction = "Compile" --- 115,124 ---- /> <File ! RelPath = "StoredPageInfo.cs" ! SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "Util.cs" SubType = "Code" BuildAction = "Compile" Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MagicAjaxModule.cs 16 Nov 2005 08:08:58 -0000 1.9 --- MagicAjaxModule.cs 17 Nov 2005 15:03:16 -0000 1.10 *************** *** 73,76 **** --- 73,77 ---- private MagicAjaxConfiguration _config; private bool _completedAjaxCall; + private bool _exceptionThrown; private PageFilter _filter; private HttpContext _context; *************** *** 95,98 **** --- 96,104 ---- } + public StoredPageInfo CurrentPageInfo + { + get { return _currentPageInfo; } + } + public bool CompletedAjaxCall { *************** *** 137,141 **** public virtual void EnableAjaxOnPage(Page page) { ! if (_isAjaxCall || page == null) return; string STARTUP_SCRIPT_FORMAT = @" --- 143,147 ---- public virtual void EnableAjaxOnPage(Page page) { ! if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; string STARTUP_SCRIPT_FORMAT = @" *************** *** 198,202 **** public virtual void AddWebPartClientFunctions(Page page) { ! if (_isAjaxCall || page == null) return; if (!HttpContext.Current.Items.Contains("AJAX_WEBPARTCLIENTSCRIPT_REGISTERED")) --- 204,208 ---- public virtual void AddWebPartClientFunctions(Page page) { ! if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; if (!HttpContext.Current.Items.Contains("AJAX_WEBPARTCLIENTSCRIPT_REGISTERED")) *************** *** 381,388 **** { case PageStoreMode.Session: ! return (ArrayList)_context.Session[key]; case PageStoreMode.Cache: ! return (ArrayList)_context.Cache[key]; default: --- 387,400 ---- { case PageStoreMode.Session: ! if (_context.Session != null) ! return (ArrayList)_context.Session[key]; ! else ! return null; case PageStoreMode.Cache: ! if (_context.Cache != null) ! return (ArrayList)_context.Cache[key]; ! else ! return null; default: *************** *** 435,438 **** --- 447,451 ---- _isAjaxCall = false; _completedAjaxCall = false; + _exceptionThrown = false; Page requestPage = (Page) _context.Handler; *************** *** 461,465 **** AjaxCallHelper.Init(); ! _context.Handler.ProcessRequest (_context); _response.Flush(); --- 474,490 ---- AjaxCallHelper.Init(); ! try ! { ! _exceptionThrown = true; ! _context.Handler.ProcessRequest (_context); ! } ! catch (System.Threading.ThreadAbortException exc) ! { ! // ThreadAbortException is for Server.Transfer, Response.Redirect ! // and AjaxCallHelper.End ! _exceptionThrown = false; ! throw exc; ! } ! _response.Flush(); *************** *** 518,523 **** if ( ! _isAjaxCall ) { ! // PostBack. Will replace the recreated controls with the stored ones ! requestPage.Load += new EventHandler(RequestedPage_Init); } else --- 543,548 ---- if ( ! _isAjaxCall ) { ! // PostBack. Get the controls from stored page. ! requestPage.Init += new EventHandler(RequestedPage_Init); } else *************** *** 532,556 **** { // Restore the validators ! ArrayList validators = FindValidators(_currentPageInfo.Page); foreach (IValidator valid in validators) _currentPageInfo.Page.Validators.Add (valid); } AjaxCallHelper.Init(); - ProcessAjaxCall(_currentPageInfo.Page); - /* try { ProcessAjaxCall(_currentPageInfo.Page); } ! catch(Exception exc) { ! string hhh = exc.Message; ! int uu=5; ! }*/ ! ! _currentPageInfo.AjaxCallsCount++; ! _currentPageInfo.LastAccess = DateTime.Now; AjaxCallHelper.End(); --- 557,582 ---- { // Restore the validators ! ArrayList validators = Util.GetChildControlsOfType(_currentPageInfo.Page, typeof(IValidator), false); foreach (IValidator valid in validators) _currentPageInfo.Page.Validators.Add (valid); } + _currentPageInfo.AjaxCallsCount++; + _currentPageInfo.LastAccess = DateTime.Now; + AjaxCallHelper.Init(); try { + _exceptionThrown = true; ProcessAjaxCall(_currentPageInfo.Page); } ! catch (System.Threading.ThreadAbortException exc) { ! // ThreadAbortException is for Server.Transfer, Response.Redirect ! // and AjaxCallHelper.End ! _exceptionThrown = false; ! throw exc; ! } AjaxCallHelper.End(); *************** *** 577,581 **** protected virtual void Application_EndRequest(object sender, EventArgs e) { ! if ( ! _isAjaxCall || _completedAjaxCall ) return; --- 603,607 ---- protected virtual void Application_EndRequest(object sender, EventArgs e) { ! if ( ! _isAjaxCall || _completedAjaxCall || _exceptionThrown) return; *************** *** 605,609 **** { // Required for Page.Request/Page.Response to be valid ! CallPrivateMethod (page, typeof(Page), "SetIntrinsics", _context); ReadOnlyArrayList postDataChangedControls; --- 631,637 ---- { // Required for Page.Request/Page.Response to be valid ! Util.CallPrivateMethod (page, typeof(Page), "SetIntrinsics", _context); ! // For bypassing the VerifyRenderingInServerForm check ! Util.SetPrivateField (page, typeof(Page), "_inOnFormRender", true); ReadOnlyArrayList postDataChangedControls; *************** *** 778,825 **** ((IPostBackEventHandler)eventcontrol).RaisePostBackEvent(eventArgument); } - - /// <summary> - /// It finds the validator controls and returns them in an ArrayList. - /// </summary> - /// <remarks> - /// After the normal rendering of the page the Page.Validators collection is empty. - /// This method is used to repopulate it. - /// </remarks> - /// <param name="control"></param> - /// <returns></returns> - protected virtual ArrayList FindValidators (Control control) - { - ArrayList list = new ArrayList(); - - for (int i=0; i < control.Controls.Count; i++) - { - Control con = control.Controls[i]; - - if (con.Visible) - { - if (con is IValidator) - { - list.Add (con); - } - - list.AddRange (FindValidators(con)); - } - } - - return list; - } - - /// <summary> - /// Call a private method from the given object. - /// </summary> - /// <param name="instance"></param> - /// <param name="type"></param> - /// <param name="methodName"></param> - /// <param name="parameters"></param> - /// <returns></returns> - protected object CallPrivateMethod(object instance, Type type, string methodName, params object[] parameters) - { - return type.GetMethod(methodName, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(instance, parameters); - } #endregion --- 806,809 ---- |