public ActionResult PostPicture(FormCollection collection) { var file = Request.Files["file"]; if (file != null && file.ContentLength > 0) { Post post = new Post(); post.ToUserId = null; post.FromUserId = User.Identity.GetUserId(); if (post.FromUserId != null) { post.GroupId = Convert.ToInt32(collection["GroupId"]); post.PosterName = _userService.GetFullNameById(User.Identity.GetUserId()); _postService.AddPost(post); string url = _helper.UploadPicture(file, post.Id.ToString(), "post", new Size(1024, 768)); _postService.AddPicUrl(post.Id, url); return(RedirectToAction("Profile", "Group", new { groupId = post.GroupId })); } } return(View("Error")); }