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)); }
public async Task <IHttpActionResult> ShortUrl([FromUri] string url) { var responseUrl = await service.CreateShortUrlForIp(HttpContext.Current.Request.UserHostAddress, url); return(Ok("/go/" + responseUrl)); }