public void ProcessRequest(HttpContext context) { var aRequestInfo = RequestInfoProvider.GetRequestInformation(); if (HttpContext.Current.Request.Url.PathAndQuery.TrimStart('/').ToLower().StartsWith(aRequestInfo.ApplicationPath.ToLower().Trim('/'))) return; var aliasSettingsManager = ObjectFactory.GetAliasSettingsManager(aRequestInfo); var settings = aliasSettingsManager.Get(); if (settings.IsAliasingEnabled) { var aCacheDuration = 5; this.TraceMessage("BEGIN Processing URL"); // Redirect if extensionless and no trailing forward slash. Backwards compatibility with pre 8.5.1. if (Path.GetExtension(context.Request.AppRelativeCurrentExecutionFilePath) == string.Empty && !context.Request.AppRelativeCurrentExecutionFilePath.EndsWith("/")) { this.TraceMessage("Missing trailing slash, forcing a Redirect."); context.Response.Clear(); context.Response.StatusCode = 301; context.Response.Status = "301 Moved Permanently"; context.Response.AddHeader("Location", context.Request.Url.LocalPath + "/" + context.Request.Url.Query); context.Response.End(); } var aCacheKey = context.Request.Url.OriginalString + aRequestInfo.ContentLanguage.ToString(); var aMessageKey = aCacheKey + "messages"; var aRequestMessages = (List<RequestValidatorCode>)HttpRuntime.Cache[aMessageKey]; if (aRequestMessages == null) { IRequestValidator requestValidator = new RequestValidator(); aRequestMessages = requestValidator.validate(context.Request.Url); HttpRuntime.Cache.Insert(aMessageKey, aRequestMessages, null, System.DateTime.UtcNow.AddMinutes(aCacheDuration), Cache.NoSlidingExpiration); } if (aRequestMessages.Count == 0) { var aTargetKey = aCacheKey + "target"; var target = (AliasData)HttpRuntime.Cache[aTargetKey]; if (target == null) { var requestManager = ObjectFactory.GetURLRequestManager(aRequestInfo); target = requestManager.GetTarget(context.Request.Url, aRequestInfo.ContentLanguage) ?? new AliasData(); HttpRuntime.Cache.Insert(aTargetKey, target, null, System.DateTime.UtcNow.AddMinutes(aCacheDuration), System.Web.Caching.Cache.NoSlidingExpiration); } // Handle Response var aResponseMessageKey = aCacheKey + "responsemessages"; var responseMessages = (List<ResponseValidatorCode>)HttpRuntime.Cache[aResponseMessageKey]; if (responseMessages == null) { IResponseValidator responseValidator = new ResponseValidator(); responseMessages = responseValidator.validate(target); HttpRuntime.Cache.Insert(aResponseMessageKey, responseMessages, null, System.DateTime.UtcNow.AddMinutes(aCacheDuration), System.Web.Caching.Cache.NoSlidingExpiration); } if (responseMessages.Count == 0) { this.processValidResponse(context, target); } else { this.processInvalidResponse(responseMessages, context); } } else { this.processInvalidRequest(aRequestMessages, context); } } else { // perform look up for default documents. processDefaultDocument(context); } }