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 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); } } } }