From: Dion O. <dol...@us...> - 2005-12-27 22:03:51
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18662/magicajax/Core Modified Files: MagicAjaxContext.cs MagicAjaxModule.cs Log Message: - Added Opera 8 support! - fix so MagicAjaxContext only gets built on an .aspx request, not for every ASP.NET 2.0 .axd (embedded resource) request Index: MagicAjaxContext.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxContext.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MagicAjaxContext.cs 22 Dec 2005 23:06:51 -0000 1.11 --- MagicAjaxContext.cs 27 Dec 2005 22:03:41 -0000 1.12 *************** *** 240,244 **** break; case "netscape": ! _isBrowserSupported = caps.MajorVersion >= 5; break; //TODO: add support for Opera, Netscape and Safari --- 240,247 ---- break; case "netscape": ! _isBrowserSupported = caps.MajorVersion >= 5; ! break; ! case "opera": ! _isBrowserSupported = caps.MajorVersion >= 8; break; //TODO: add support for Opera, Netscape and Safari Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** MagicAjaxModule.cs 26 Dec 2005 02:27:20 -0000 1.53 --- MagicAjaxModule.cs 27 Dec 2005 22:03:42 -0000 1.54 *************** *** 397,428 **** HttpContext context = ((HttpApplication)sender).Context; ! // Init private fields ! _threadAbortExceptionThrown = false; ! _processedAjaxCall = false; ! _request = context.Request; ! _response = context.Response; ! ! // Create a new context and add it to the items collection for later retrieval ! // by MagicAjaxContext.Current ! _magicAjaxContext = new MagicAjaxContext(); ! HttpContext.Current.Items.Add(MagicAjaxContext.ContextKey, _magicAjaxContext); ! ! // Check if the request is for the embedded AjaxCallObject.js script ! if (context.Request.RawUrl.EndsWith("AjaxCallObject.js.aspx")) { ! context.Response.ContentType = "text/javascript"; ! object cachedAjaxCallObjectJs = context.Cache["__CACHED_AJAXCALLOBJECT_JS"]; ! if (cachedAjaxCallObjectJs == null) { ! //read and output the embedded AjaxCallObject.js file from the manifest ! using (System.IO.StreamReader reader = new System.IO.StreamReader(typeof(MagicAjaxModule).Assembly.GetManifestResourceStream("MagicAjax.script.AjaxCallObject.js"))) { ! cachedAjaxCallObjectJs = reader.ReadToEnd(); } ! context.Cache.Insert("__CACHED_AJAXCALLOBJECT_JS", cachedAjaxCallObjectJs); } - context.Response.Write(cachedAjaxCallObjectJs); - context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); - context.Response.End(); } } --- 397,433 ---- HttpContext context = ((HttpApplication)sender).Context; ! if (context.Request.Url.AbsolutePath.EndsWith(".aspx")) { ! // Check if the request is for the embedded AjaxCallObject.js script ! if (context.Request.RawUrl.EndsWith("AjaxCallObject.js.aspx")) { ! context.Response.ContentType = "text/javascript"; ! object cachedAjaxCallObjectJs = context.Cache["__CACHED_AJAXCALLOBJECT_JS"]; ! if (cachedAjaxCallObjectJs == null) { ! //read and output the embedded AjaxCallObject.js file from the manifest ! using (System.IO.StreamReader reader = new System.IO.StreamReader(typeof(MagicAjaxModule).Assembly.GetManifestResourceStream("MagicAjax.script.AjaxCallObject.js"))) ! { ! cachedAjaxCallObjectJs = reader.ReadToEnd(); ! } ! context.Cache.Insert("__CACHED_AJAXCALLOBJECT_JS", cachedAjaxCallObjectJs); } ! context.Response.Write(cachedAjaxCallObjectJs); ! context.Response.Cache.SetExpires(DateTime.Now.AddYears(1)); ! context.Response.End(); ! } ! else ! { ! // Init private fields ! _threadAbortExceptionThrown = false; ! _processedAjaxCall = false; ! _request = context.Request; ! _response = context.Response; ! ! // Create a new context and add it to the items collection for later retrieval ! // by MagicAjaxContext.Current ! _magicAjaxContext = new MagicAjaxContext(); ! HttpContext.Current.Items.Add(MagicAjaxContext.ContextKey, _magicAjaxContext); } } } *************** *** 437,441 **** HttpApplication application = (HttpApplication) sender; ! if (!_request.Url.AbsolutePath.EndsWith(".aspx")) { return; //if this wasn't a .aspx request, don't process --- 442,446 ---- HttpApplication application = (HttpApplication) sender; ! if (_request == null || !_request.Url.AbsolutePath.EndsWith(".aspx")) { return; //if this wasn't a .aspx request, don't process *************** *** 612,615 **** --- 617,623 ---- protected void Application_EndRequest(object sender, EventArgs e) { + if (_request == null) + return; + try { |