Esempio n. 1
0
        public async Task <JsonResult> GetShortUrl(string url)
        {
            string shortUrl;

            if (User.Identity.IsAuthenticated)
            {
                shortUrl = await urlService.CreateShortUrlForUser(Guid.Parse(User.Identity.GetUserId()), url);
            }
            else
            {
                shortUrl = await urlService.CreateShortUrlForIp(Request.UserHostAddress, url);
            }
            return(Json(Url.RouteUrl("go", new { shorturl = shortUrl }), JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> ShortUrl([FromUri] string url)
        {
            var responseUrl = await service.CreateShortUrlForIp(HttpContext.Current.Request.UserHostAddress, url);

            return(Ok("/go/" + responseUrl));
        }