示例#1
0
        public ActionResult <string> Get(string id)
        {
            var url = _shortenerService.Get(id);

            if (url is null)
            {
                return(NotFound());
            }

            return(RedirectPermanent(url.FullUrl));
        }
示例#2
0
 public ActionResult Index(string key)
 {
     if (string.IsNullOrWhiteSpace(key))
     {
         return(View());
     }
     else
     {
         ShortUrl url = _service.Get(key);
         if (url != null)
         {
             _service.AddClick(url.Id, Request.UserHostAddress);
             return(new RedirectResult(url.Full, true));
         }
         else
         {
             return(View());
         }
     }
 }