internal String MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, bool allowCrossAppMapping) { if (_wr == null) throw new HttpException(SR.GetString(SR.Cannot_map_path_without_context)); // treat null as "." // if (virtualPath == null) virtualPath = VirtualPath.Create("."); VirtualPath originalVirtualPath = virtualPath; // remember for patch-up at the end // Combine it with the base if one was passed in if (baseVirtualDir != null) { virtualPath = baseVirtualDir.Combine(virtualPath); } if (!allowCrossAppMapping) virtualPath.FailIfNotWithinAppRoot(); string realPath = virtualPath.MapPathInternal(); // patch up the result for Everett combatibility (VSWhidbey 319826) if (virtualPath.VirtualPathString == "/" && originalVirtualPath.VirtualPathString != "/" && !originalVirtualPath.HasTrailingSlash && UrlPath.PathEndsWithExtraSlash(realPath)) { realPath = realPath.Substring(0, realPath.Length - 1); } InternalSecurityPermissions.PathDiscovery(realPath).Demand(); return realPath; }
private XmlDocument GetConfigDocument() { if (_document != null) { return(_document); } if (!_initialized) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Not_Initialized)); } // Do the error checking here if (_virtualPath == null) { throw new ArgumentException( SR.GetString(SR.XmlSiteMapProvider_missing_siteMapFile, _siteMapFileAttribute)); } if (!_virtualPath.Extension.Equals(_xmlSiteMapFileExtension, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Invalid_Extension, _virtualPath)); } _normalizedVirtualPath = _virtualPath.CombineWithAppRoot(); _normalizedVirtualPath.FailIfNotWithinAppRoot(); // Make sure the file exists CheckSiteMapFileExists(); _parentSiteMapFileCollection = new StringCollection(); XmlSiteMapProvider xmlParentProvider = ParentProvider as XmlSiteMapProvider; if (xmlParentProvider != null && xmlParentProvider._parentSiteMapFileCollection != null) { if (xmlParentProvider._parentSiteMapFileCollection.Contains(_normalizedVirtualPath.VirtualPathString)) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_FileName_already_in_use, _virtualPath)); } // Copy the sitemapfiles in used from parent provider to current provider. foreach (string filename in xmlParentProvider._parentSiteMapFileCollection) { _parentSiteMapFileCollection.Add(filename); } } // Add current sitemap file to the collection _parentSiteMapFileCollection.Add(_normalizedVirtualPath.VirtualPathString); _filename = HostingEnvironment.MapPathInternal(_normalizedVirtualPath); if (!String.IsNullOrEmpty(_filename)) { _handler = new FileChangeEventHandler(this.OnConfigFileChange); HttpRuntime.FileChangesMonitor.StartMonitoringFile(_filename, _handler); ResourceKey = (new FileInfo(_filename)).Name; } _document = new ConfigXmlDocument(); return(_document); }
internal void RewritePath(VirtualPath filePath, VirtualPath pathInfo, String queryString, bool setClientFilePath) { EnsureHasNotTransitionedToWebSocket(); if (filePath == null) throw new ArgumentNullException("filePath"); // resolve relative path filePath = Request.FilePathObject.Combine(filePath); // disallow paths outside of app filePath.FailIfNotWithinAppRoot(); // clear things that depend on path ConfigurationPath = null; // rewrite path on request Request.InternalRewritePath(filePath, pathInfo, queryString, setClientFilePath); }
internal string MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, bool allowCrossAppMapping) { if (this._wr == null) { throw new HttpException(System.Web.SR.GetString("Cannot_map_path_without_context")); } if (virtualPath == null) { virtualPath = VirtualPath.Create("."); } VirtualPath path = virtualPath; if (baseVirtualDir != null) { virtualPath = baseVirtualDir.Combine(virtualPath); } if (!allowCrossAppMapping) { virtualPath.FailIfNotWithinAppRoot(); } string str = virtualPath.MapPathInternal(); if (((virtualPath.VirtualPathString == "/") && (path.VirtualPathString != "/")) && (!path.HasTrailingSlash && UrlPath.PathEndsWithExtraSlash(str))) { str = str.Substring(0, str.Length - 1); } InternalSecurityPermissions.PathDiscovery(str).Demand(); return str; }
private XmlDocument GetConfigDocument() { if (_document != null) return _document; if (!_initialized) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Not_Initialized)); } // Do the error checking here if (_virtualPath == null) { throw new ArgumentException( SR.GetString(SR.XmlSiteMapProvider_missing_siteMapFile, _siteMapFileAttribute)); } if (!_virtualPath.Extension.Equals(_xmlSiteMapFileExtension, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Invalid_Extension, _virtualPath)); } _normalizedVirtualPath = _virtualPath.CombineWithAppRoot(); _normalizedVirtualPath.FailIfNotWithinAppRoot(); // Make sure the file exists CheckSiteMapFileExists(); _parentSiteMapFileCollection = new StringCollection(); XmlSiteMapProvider xmlParentProvider = ParentProvider as XmlSiteMapProvider; if (xmlParentProvider != null && xmlParentProvider._parentSiteMapFileCollection != null) { if (xmlParentProvider._parentSiteMapFileCollection.Contains(_normalizedVirtualPath.VirtualPathString)) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_FileName_already_in_use, _virtualPath)); } // Copy the sitemapfiles in used from parent provider to current provider. foreach (string filename in xmlParentProvider._parentSiteMapFileCollection) { _parentSiteMapFileCollection.Add(filename); } } // Add current sitemap file to the collection _parentSiteMapFileCollection.Add(_normalizedVirtualPath.VirtualPathString); _filename = HostingEnvironment.MapPathInternal(_normalizedVirtualPath); if (!String.IsNullOrEmpty(_filename)) { _handler = new FileChangeEventHandler(this.OnConfigFileChange); HttpRuntime.FileChangesMonitor.StartMonitoringFile(_filename, _handler); ResourceKey = (new FileInfo(_filename)).Name; } _document = new ConfigXmlDocument(); return _document; }
internal void RewritePath(VirtualPath filePath, VirtualPath pathInfo, string queryString, bool setClientFilePath) { if (filePath == null) { throw new ArgumentNullException("filePath"); } filePath = this.Request.FilePathObject.Combine(filePath); filePath.FailIfNotWithinAppRoot(); this.ConfigurationPath = null; this.Request.InternalRewritePath(filePath, pathInfo, queryString, setClientFilePath); }