Пример #1
0
        /// <summary>
        /// 上传并返回结果,已处理跨域Jsonp请求
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <UEditorResponse> UploadAndGetResponse(HttpContext context)
        {
            var    action = context.Request.Query["action"];
            object result;

            if (AppConsts.Action.Config.Equals(action, StringComparison.OrdinalIgnoreCase))
            {
                var configHandle = new ConfigHandler();
                result = configHandle.Process();
            }
            else
            {
                var handle = HandelFactory.GetHandler(action, context);
                result = await handle.Process();
            }
            string resultJson = JsonConvert.SerializeObject(result, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });
            string contentType   = "text/plain";
            string jsonpCallback = context.Request.Query["callback"];

            if (!String.IsNullOrWhiteSpace(jsonpCallback))
            {
                contentType = "application/javascript";
                resultJson  = string.Format("{0}({1});", jsonpCallback, resultJson);
                UEditorResponse response = new UEditorResponse(contentType, resultJson);
                return(response);
            }
            else
            {
                UEditorResponse response = new UEditorResponse(contentType, resultJson);
                return(response);
            }
        }
Пример #2
0
        /// <summary>
        /// 单纯的上传并返回结果,未处理跨域Jsonp请求
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public object Upload(HttpContext context)
        {
            var    action = context.Request.Query["action"];
            object result;

            if (AppConsts.Action.Config.Equals(action, StringComparison.OrdinalIgnoreCase))
            {
                result = new ConfigHandler();
            }
            else
            {
                var handle = HandelFactory.GetHandler(action, context);
                result = handle.Process();
            }
            return(result);
        }