예제 #1
0
        public ActionResult RedirectToUrl(string ShortUrl)
        {
            var RegisteredUrl = _urlService.GetRegisteredUrl(ShortUrl);

            if (RegisteredUrl != null)
            {
                if (RegisteredUrl.RedirectType > 0)
                {
                    if (RegisteredUrl.RedirectType == 301)
                    {
                        _urlService.IncrementStatistic(RegisteredUrl.RegisteredUrlID);
                        return(RedirectPermanent(RegisteredUrl.LongUrl));
                    }
                    else if (RegisteredUrl.RedirectType == 302)
                    {
                        _urlService.IncrementStatistic(RegisteredUrl.RegisteredUrlID);
                        return(Redirect(RegisteredUrl.LongUrl));
                    }
                }
                return(Redirect(RegisteredUrl.LongUrl)); //za svaki slucaj ako je redirectType = null ili 0
            }
            return(NotFound());
        }