public override void OnProcessRequest(HttpContext context)
        {
            if (!string.IsNullOrEmpty(context.Request["submit"]))
            {
                FileUploadHandler.FileUploadResult result;
                try
                {
                    var uploadHandler = (FileUploadHandler)Activator.CreateInstance(Type.GetType(context.Request["submit"], true));
                    result = uploadHandler.ProcessUpload(context);
                }
                catch (Exception ex)
                {
                    result = new FileUploadHandler.FileUploadResult
                    {
                        Success = false,
                        Message = ex.Message.HtmlEncode(),
                    };
                }

                //NOTE: Don't set content type. ie cant parse it
                context.Response.StatusCode = 200;
                context.Response.Write(JavaScriptSerializer.Serialize(result));
            }
            else
            {
                context.Response.StatusCode = 400;
                context.Response.Write("Not found submit parameter.");
            }
        }
        public override void OnProcessRequest(HttpContext context)
        {
            if (!string.IsNullOrEmpty(context.Request["submit"]))
            {
                FileUploadHandler.FileUploadResult result;
                try
                {
                    var uploadHandler = (FileUploadHandler)Activator.CreateInstance(Type.GetType(context.Request["submit"], true));
                    result = uploadHandler.ProcessUpload(context);
                }
                catch (Exception ex)
                {
                    result = new FileUploadHandler.FileUploadResult
                    {
                        Success = false,
                        Message = ex.Message.HtmlEncode(),
                    };
                }

                //NOTE: Don't set content type. ie cant parse it
                context.Response.StatusCode = 200;
                context.Response.Write(JavaScriptSerializer.Serialize(result));
            }
            else
            {
                context.Response.ContentType = "application/json";
                var id = context.Request.QueryString[UploadProgressStatistic.UploadIdField];
                var us = UploadProgressStatistic.GetStatistic(id);

                if (!string.IsNullOrEmpty(context.Request["limit"]))
                {
                    var limit = long.Parse(context.Request["limit"]);
                    if (us.TotalBytes > limit)
                    {
                        us.ReturnCode = 1;
                        us.IsFinished = true;
                    }
                }

                context.Response.Write(us.ToJson());
            }
        }
        public override void OnProcessRequest(HttpContext context)
        {
            if (!string.IsNullOrEmpty(context.Request["submit"]))
            {
                FileUploadHandler.FileUploadResult result;
                try
                {
                    var uploadHandler = (FileUploadHandler)Activator.CreateInstance(Type.GetType(context.Request["submit"], true));
                    result = uploadHandler.ProcessUpload(context);
                }
                catch (Exception ex)
                {
                    result = new FileUploadHandler.FileUploadResult
                        {
                            Success = false,
                            Message = ex.Message.HtmlEncode(),
                        };
                }

                //NOTE: Don't set content type. ie cant parse it
                context.Response.StatusCode = 200;
                context.Response.Write(JavaScriptSerializer.Serialize(result));
            }
            else
            {
                context.Response.ContentType = "application/json";
                var id = context.Request.QueryString[UploadProgressStatistic.UploadIdField];
                var us = UploadProgressStatistic.GetStatistic(id);

                if (!string.IsNullOrEmpty(context.Request["limit"]))
                {
                    var limit = long.Parse(context.Request["limit"]);
                    if (us.TotalBytes > limit)
                    {
                        us.ReturnCode = 1;
                        us.IsFinished = true;
                    }
                }

                context.Response.Write(us.ToJson());
            }
        }