// GET: Clipp public async Task <ActionResult> Index(string id) { UniqueKeyGenerator keygen = new UniqueKeyGenerator(); if (Request.IsAuthenticated) { if (!string.IsNullOrWhiteSpace(id)) { RedirectToAction("Index"); } var userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); var user = await userManager.FindByIdAsync(User.Identity.GetUserId()); id = user.ClippCode; // the following should never happen, but... if (string.IsNullOrWhiteSpace(id)) { id = keygen.GenerateKey(); user.ClippCode = id; await userManager.UpdateAsync(user); } } if (string.IsNullOrWhiteSpace(id)) { return(RedirectToAction("Index", new { id = keygen.GenerateKey() })); } var service = new FileUploadService(new Logger()); var text = await service.RetrieveText(id); var model = new ClippViewModel() { UniqueKey = id, Text = text, IsAuthenticated = Request.IsAuthenticated }; return(View(model)); }