예제 #1
0
        public override void Process(HttpRequestArgs args)
        {
            if (!ShouldRun(args))
            {
                return;
            }

            var requestDomain = args.RequestUrl.AbsoluteUri;
            var serviceDomain = _settingsRepository.GetDomain();

            if (!requestDomain.Contains(serviceDomain))
            {
                return;
            }

            var shorthand = args.RequestUrl.Segments[1];
            var shortUrl  = _shortUrlRepository.GetShortUrlEntryByShorthand(shorthand);

            args.HttpContext.Response.RedirectPermanent(shortUrl == null
                ? _settingsRepository.GetFallbackUrl().Url
                : shortUrl.Destination.Url);

            args.AbortPipeline();
        }