Moved ProviderCollectionTest.cs from System assembly to System.Configuration.
[mono.git] / mcs / class / System.Web.Extensions / System.Web.Handlers / ScriptModule.cs
index 9647615228018a8ff870f2b138b19b82ba2643f7..bf4bad4bfce183594ff96e3cfc37abf1a5a50c2a 100644 (file)
@@ -67,8 +67,16 @@ namespace System.Web.Handlers
                        HttpContext context = app.Context;\r
                        HttpRequest request = context.Request;\r
                        string contentType = request.ContentType;\r
-                       if (context.CurrentHandler is Page && !String.IsNullOrEmpty (contentType) && contentType.StartsWith ("application/json", StringComparison.OrdinalIgnoreCase)) {\r
-                               IHttpHandler h = RestHandler.GetHandler(context, ((Page) context.CurrentHandler).GetType (), request.FilePath);\r
+                       Type pageType = context.CurrentHandler.GetType ();\r
+#if TARGET_J2EE\r
+                       if (!(context.CurrentHandler is Page) && context.CurrentHandler is IServiceProvider) {\r
+                               pageType = (Type) ((IServiceProvider) context.CurrentHandler).GetService (typeof (Type));\r
+                               if (pageType == null)\r
+                                       return;\r
+                       }\r
+#endif\r
+                       if (typeof (Page).IsAssignableFrom (pageType) && !String.IsNullOrEmpty (contentType) && contentType.StartsWith ("application/json", StringComparison.OrdinalIgnoreCase)) {\r
+                               IHttpHandler h = RestHandler.GetHandler (context, pageType, request.FilePath);\r
                                h.ProcessRequest (context);\r
                                app.CompleteRequest ();\r
                        }\r
@@ -79,6 +87,10 @@ namespace System.Web.Handlers
                        HttpContext context = app.Context;\r
                        if (context.Request.Headers ["X-MicrosoftAjax"] == "Delta=true") {\r
                                Page p = context.CurrentHandler as Page;\r
+#if TARGET_J2EE\r
+                               if (p == null && context.CurrentHandler is IServiceProvider)\r
+                                       p = (Page) ((IServiceProvider) context.CurrentHandler).GetService (typeof (Page));\r
+#endif\r
                                if (p == null)\r
                                        return;\r
                                ScriptManager sm = ScriptManager.GetCurrent (p);\r