Ejemplo n.º 1
0
        public ActionResult ShortenUrl(ShortenUrlViewModel model)
        {
            var shortUrl = urlShortener.ShortenUrl(model.LongUrl);

            return(View(new ShortenUrlViewModel {
                ShortUrl = shortUrl
            }));
        }
Ejemplo n.º 2
0
        public ViewResult ShortenUrl(ShortenUrlViewModel request)
        {
            if (!request.Url.Contains(":"))
            {
                request.Url = @"http://" + request.Url;
            }

            var urlId    = service.CreateUrlIdentifier(request.Url);
            var shortUrl = Request.Url.Scheme + @"://" + Request.Url.Authority + @"/" + urlId;

            request.ShortenedUrl = shortUrl;
            return(View(request));
        }