public ActionResult Upload(HttpPostedFileBase image) { if (image != null && (image.ContentType == "image/jpg" || image.ContentType == "image/png" || image.ContentType == "image/jpeg")) { var img = new Photo() { MimeType = image.ContentType, Data = new byte[image.ContentLength] }; image.InputStream.Read(img.Data, 0, image.ContentLength); photoService.AddAvatarToUser(img, User.Identity.Name); if (Request.IsAjaxRequest()) { } return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }