public ActionResult URLForm(ShortnerViewModel shortnerViewModel) { int lastId; if (ModelState.IsValid) { URLModel newModel = new URLModel { LongURL = shortnerViewModel.SingleURL.LongURL, ClickCount = 0 }; lastId = ShortnerService.AddURL(newModel, HttpContext.Request.Url.Host, HttpContext.Request.Url.Port, Session["UserID"].ToString()); if (string.IsNullOrEmpty(Session["UserID"].ToString())) { CookieController.AddToCookie($".{lastId}"); } ShortnerService.SaveURL(); } else { ModelState.AddModelError("", ""); } return(RedirectToAction("Index", "Home")); }