public async Task <IActionResult> OnPostAsync()
        {
            InputUrl = InputUrl.Trim().ToLower();

            string hash        = Functions.GenerateRandomHash(5);
            var    existingUrl = await _urlRepo.GetUrlByOriginalUrl(hash);

            do
            {
                hash = Functions.GenerateRandomHash(5);
                var exits = await _urlRepo.GetUrlByShortUrl(hash);

                if (exits == null)
                {
                    break;
                }
            } while (existingUrl != null && hash == existingUrl.ShortUrl);

            if (!ModelState.IsValid)
            {
                Message = "Something went wrong, please try again";

                return(Page());
            }
            else if (!Functions.CheckValidUrl(InputUrl))
            {
                Message = "Something went wrong, your url is not valid and could not be validated before being posted to the server. Please try again.";
                _log.LogWarning("Javascript validation failed.");

                return(Page());
            }

            newUrl.ShortUrl    = hash;
            newUrl.OriginalUrl = InputUrl;
            newUrl.CreatedDate = DateTime.Now;
            newUrl.Counter     = 0;
            newUrl.IP          = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();

            await _urlRepo.AddUrl(newUrl);

            return(RedirectToPage("/Index"));
        }