public async Task <ActionResult> IndexAsync(HttpPostedFileBase file) { if (file?.ContentLength > 0) { var pictureName = Guid.NewGuid().ToString(); pictureName += Path.GetExtension(file.FileName); var route = Server.MapPath(serverFolderPath);//optiene la ruta absoluta de la carpeta if (!Directory.Exists(route)) { Directory.CreateDirectory(route); } route = route + "/" + pictureName; file.SaveAs(@route); var emoPicture = await emoHelper.DetectAndExtractFacesAsync(file.InputStream); emoPicture.Name = file.FileName; emoPicture.Path = $"{serverFolderPath}/{pictureName}"; using (EmotionWebContext database = new EmotionWebContext()) { db.EmoPictures.Add(emoPicture); await db.SaveChangesAsync(); } return(RedirectToAction("Details", "EmoPictures", new { Id = emoPicture.Id })); } return(View()); }