Exemplo n.º 1
0
        /// <summary>
        /// Handle the actual callback by deferring to JsonCallbackMethodProcessor()
        /// </summary>
        /// <param name="context"></param>
        public virtual void ProcessRequest(HttpContext context)
        {
            Request  = context.Request;
            Response = context.Response;
            Context  = context;

            var pathInfo = Request.PathInfo;

            // handle WCF/ASMX style type wrappers for handler implementation
            // returns a separate dynamic link with the JavaScript Service Proxy
            if (pathInfo == "/jsdebug" ||
                pathInfo == "/js")
            {
                GenerateClassWrapperForCallbackMethods();
                return;
            }

            // Pass off to the worker Callback Processor

            ICallbackMethodProcessor processor;

            // default format is JSON - check for others
            string format = (context.Request.Params["format"] ?? "").ToLower();

            // check accept types
            if (string.IsNullOrEmpty(format))
            {
                if (context.Request.AcceptTypes.Where(str => str.Contains(ControlResources.STR_JsonContentType) || str.Contains(ControlResources.STR_JavaScriptContentType)).Count() > 0)
                {
                    format = "json";
                }
                else if (context.Request.AcceptTypes.Where(str => str.Contains(ControlResources.STR_XmlContentType)).Count() > 0)
                {
                    format = "xml";
                }
            }

            if (format == "xml")
            {
                processor = new XmlCallbackMethodProcessor();
            }
            else
            {
                processor = new JsonCallbackMethodProcessor();
            }

            // Process the inbound request and execute it on this
            // Http Handler's methods
            processor.ProcessCallbackMethodCall(this);

            Request  = null;
            Response = null;
            Context  = null;
        }
        /// <summary>
        /// Handle the actual callback by deferring to JsonCallbackMethodProcessor()
        /// </summary>
        /// <param name="context"></param>
        public virtual void ProcessRequest(HttpContext context)
        {
            Request = context.Request;
            Response = context.Response;
            Context = context;

            var pathInfo = Request.PathInfo;
            // handle WCF/ASMX style type wrappers for handler implementation
            // returns a separate dynamic link with the JavaScript Service Proxy
            if (pathInfo == "/jsdebug" ||
                pathInfo == "/js")
            {
                GenerateClassWrapperForCallbackMethods();
                return;
            }

            // Pass off to the worker Callback Processor

            ICallbackMethodProcessor processor;

            // default format is JSON - check for others
            string format = (context.Request.Params["format"] ?? "").ToLower();

            // check accept types
            if (string.IsNullOrEmpty(format))
            {
                if (context.Request.AcceptTypes.Where(str => str.Contains(ControlResources.STR_JsonContentType) || str.Contains(ControlResources.STR_JavaScriptContentType)).Count() > 0)
                    format = "json";
                else if (context.Request.AcceptTypes.Where(str => str.Contains(ControlResources.STR_XmlContentType)).Count() > 0)
                    format = "xml";
            }

            if (format == "xml")
                processor = new XmlCallbackMethodProcessor();
            else
                processor = new JsonCallbackMethodProcessor();

            // Process the inbound request and execute it on this 
            // Http Handler's methods 
            processor.ProcessCallbackMethodCall(this);

            Request = null;
            Response = null;
            Context = null;
        }