public ActionResult Create(PhotoVM model, HttpPostedFileBase photo) { Thread.Sleep(5000); var identity = User.Identity.Name; int?userID = Userrepo.GetID(identity); model.UserID = (int)userID; model.DatePosted = DateTime.Now; string photoFolder = Server.MapPath("~/Images"); var path = string.Empty; var fileName = string.Empty; if (photo != null && photo.ContentLength > 0) { var rek = repo.GetNewIndex(); fileName = "pc" + rek + "al" + model.AlbumID + Path.GetFileName(photo.FileName); if (!Helpers.IsFilePhoto(fileName)) { return(Content("Filen måste ha formatet png, jpg or jpeg")); } path = Path.Combine(photoFolder, fileName); photo.SaveAs(path); } else { return(Content("Du måste välja en fil!")); } model.Path = "~/Images/" + fileName; if (ModelState.IsValid) { var newPhoto = ModelMapper.ModelToEntity(model); repo.AddOrUpdate(newPhoto); return(Content("Added fil")); //return Json(Url.Action("ViewAlbum", "Album", new { id = model.AlbumID })); } var result1 = "nånting gick fel"; return(Json(Request.UrlReferrer.ToString())); }