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));
        }