示例#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 == null ||
                    context.Request.AcceptTypes.Where(str => str.Contains(WebResources.STR_JsonContentType) || str.Contains(WebResources.STR_JavaScriptContentType)).Count() > 0)
                {
                    format = "json";
                }
                else if (context.Request.AcceptTypes.Where(str => str.Contains(WebResources.STR_XmlContentType) || str.Contains(WebResources.STR_XmlApplicationContentType)).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 == null ||
                    context.Request.AcceptTypes.Where(str => str.Contains(WebResources.STR_JsonContentType) || str.Contains(WebResources.STR_JavaScriptContentType)).Count() > 0)
                    format = "json";
                else if (context.Request.AcceptTypes.Where(str => str.Contains(WebResources.STR_XmlContentType) || str.Contains(WebResources.STR_XmlApplicationContentType)).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;
        }