public async Task<ActionResult> Index(Url url) { if (ModelState.IsValid) { ShortUrl shortUrl = await this._urlManager.ShortenUrl(url.LongURL, Request.UserHostAddress, url.CustomSegment); url.ShortURL = string.Format("{0}://{1}{2}{3}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"), shortUrl.Segment); } return View(url); }
public async Task<Url> Shorten([FromUri]string url, [FromUri]string segment = "") { ShortUrl shortUrl = await this._urlManager.ShortenUrl(HttpUtility.UrlDecode(url), HttpContext.Current.Request.UserHostAddress, segment); Url urlModel = new Url() { LongURL = url, ShortURL = string.Format("{0}://{1}/{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority, shortUrl.Segment) }; return urlModel; }
public ActionResult Index() { Url url = new Url(); return View(url); }