public override void Process(HttpRequestArgs args) { Item item = Context.Item; if (Context.Database == null || item == null) { return; } if (Context.PageMode.IsExperienceEditor || Context.PageMode.IsPreview) { return; } string itemId = item.ID.ToString(); Redirect resolvedMapping = this.GetResolvedMapping(itemId); bool flag = resolvedMapping != null; if (resolvedMapping == null) { resolvedMapping = this.FindMapping(itemId); } if (resolvedMapping != null && !flag) { Dictionary <string, Redirect> dictionaryitem = HttpRuntime.Cache[this.ResolvedRedirectPrefix] as Dictionary <string, Redirect> ?? new Dictionary <string, Redirect>(); dictionaryitem[itemId] = resolvedMapping; Cache cache = HttpRuntime.Cache; string resolvedMappingsPrefix = this.ResolvedRedirectPrefix; DateTime utcNow = DateTime.UtcNow; cache.Add(resolvedMappingsPrefix, dictionaryitem, null, utcNow.AddMinutes((double)this.CacheExpiration), TimeSpan.Zero, CacheItemPriority.Normal, null); } if (resolvedMapping != null && HttpContext.Current != null) { if (!resolvedMapping.RedirectUrl.IsNullOrEmpty()) { HttpContext.Current.Response.Redirect(resolvedMapping.RedirectUrl, true); args.AbortPipeline(); } } }
protected virtual Redirect FindMapping(string itemId) { Redirect redirectMapping = null; List <Redirect> .Enumerator enumerator = this.MappingsMap.GetEnumerator(); try { while (enumerator.MoveNext()) { Redirect current = enumerator.Current; if (itemId == current.TargetItemId) { redirectMapping = current; return(redirectMapping); } } } finally { ((IDisposable)enumerator).Dispose(); } return(redirectMapping); }