Update of /cvsroot/magicajax/magicajax/Core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8265/magicajax/Core
Modified Files:
MagicAjaxModule.cs
Log Message:
Added Application_BeginRequest handler to return the embedded "AjaxCallObject.js" script on requests to "AjaxCallObject.js.aspx".
So the javascript of AjaxCallObject.js isn't visible in the html source now.
Index: MagicAjaxModule.cs
===================================================================
RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** MagicAjaxModule.cs 18 Nov 2005 18:53:07 -0000 1.15
--- MagicAjaxModule.cs 18 Nov 2005 19:55:25 -0000 1.16
***************
*** 122,125 ****
--- 122,126 ----
_config = new MagicAjaxConfiguration(null);
application.AcquireRequestState += new EventHandler(Application_AcquireRequestState);
+ application.BeginRequest += new EventHandler(Application_BeginRequest);
application.EndRequest += new EventHandler(Application_EndRequest);
}
***************
*** 163,174 ****
{
#if NET_2_0
! //use the webresource url for AjaxCallObject.js
includeScript = String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", page.ClientScript.GetWebResourceUrl(typeof(MagicAjaxModule), "MagicAjax.script.AjaxCallObject.js"));
#else
! //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")))
! {
! includeScript = String.Format("<script type=\"text/javascript\">\r\n<!--\r\n{0}\r\n//-->\r\n</script>", reader.ReadToEnd());
! }
#endif
}
--- 164,172 ----
{
#if NET_2_0
! // Use the webresource url for AjaxCallObject.js
includeScript = String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", page.ClientScript.GetWebResourceUrl(typeof(MagicAjaxModule), "MagicAjax.script.AjaxCallObject.js"));
#else
! // src-request to "AjaxCallObject.js.aspx" will be handled by Application_BeginRequest, which returns the embedded AjaxCallObject.js script
! includeScript = String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", "AjaxCallObject.js.aspx");
#endif
}
***************
*** 422,425 ****
--- 420,452 ----
/// <summary>
+ /// Handles the BeginRequest event of the HttpApplication
+ /// Currently only used to return the embedded "AjaxCallObject.js" script
+ /// on requests to "AjaxCallObject.js.aspx"
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ void Application_BeginRequest(object sender, EventArgs e)
+ {
+ HttpContext context = ((HttpApplication)sender).Context;
+
+ // 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.Response.Write(cachedAjaxCallObjectJs);
+ context.Response.End();
+ }
+ }
+
+ /// <summary>
/// Handles the AcquireRequestState event of the HttpApplication
/// </summary>
***************
*** 649,652 ****
--- 676,683 ----
Util.CallPrivateMethod (page, typeof(Page), "SetIntrinsics", _context);
+ #if NET_2_0
+ Util.CallPrivateMethod(page, typeof(Page), "ProcessRequest");
+ #endif
+
ReadOnlyArrayList postDataChangedControls;
postDataChangedControls = new ReadOnlyArrayList(LoadFormDataOnChildren(page));
|