private bool HandleDefaultDocument(RewriteContext context) { Uri uri = new Uri(ContextFacade.GetRequestUrl(), context.Location); UriBuilder b = new UriBuilder(uri); b.Path += "/"; uri = b.Uri; if (uri.Host == ContextFacade.GetRequestUrl().Host) { string filename = ContextFacade.MapPath(uri.AbsolutePath); if (Directory.Exists(filename)) { foreach (string document in RewriterConfiguration.Current.DefaultDocuments) { string pathName = Path.Combine(filename, document); if (File.Exists(pathName)) { context.Location = new Uri(uri, document).AbsolutePath; return(true); } } } } return(false); }
private void SetContextItems(RewriteContext context) { OriginalQueryString = new Uri(ContextFacade.GetRequestUrl(), ContextFacade.GetRawUrl()).Query.Replace("?", ""); QueryString = new Uri(ContextFacade.GetRequestUrl(), context.Location).Query.Replace("?", ""); // Add in the properties as context items, so these will be accessible to the handler foreach (string key in context.Properties.Keys) { ContextFacade.SetItem(String.Format("Rewriter.{0}", key), context.Properties[key]); } }
private void VerifyResultExists(RewriteContext context) { if ((String.Compare(context.Location, ContextFacade.GetRawUrl()) != 0) && ((int)context.StatusCode < 300)) { Uri uri = new Uri(ContextFacade.GetRequestUrl(), context.Location); if (uri.Host == ContextFacade.GetRequestUrl().Host) { string filename = ContextFacade.MapPath(uri.AbsolutePath); if (!File.Exists(filename)) { _configuration.Logger.Debug(MessageProvider.FormatString(Message.ResultNotFound, filename)); context.StatusCode = HttpStatusCode.NotFound; } else { HandleDefaultDocument(context); } } } }