public ActionResult AsyncUpload() { Stream stream = null; var fileName = ""; var contentType = ""; if (String.IsNullOrEmpty(Request["qqfile"])) { HttpPostedFileBase httpPostedFile = Request.Files[0]; if (httpPostedFile == null) { throw new ArgumentException("No file uploaded"); } stream = httpPostedFile.InputStream; fileName = Path.GetFileName(httpPostedFile.FileName); contentType = httpPostedFile.ContentType; } else { stream = Request.InputStream; fileName = Request["qqfile"]; } var fileBinary = new byte[stream.Length]; stream.Read(fileBinary, 0, fileBinary.Length); var fileExtension = Path.GetExtension(fileName); if (!String.IsNullOrEmpty(fileExtension)) { fileExtension = fileExtension.ToLowerInvariant(); } var resource = _resourcesService.InsertResources(fileBinary, contentType, fileName); return(Json(new { success = true, pictureId = resource.Id, imageUrl = _resourcesService.GetResourcesUrl(resource) }, MimeTypes.TextPlain)); //ResourceModel model = new ResourceModel //{ // Id = resource.Id //}; //return RedirectToAction("Edit", new { id = 113 }); }