static internal void GetSiteIDAndVPathFromConfigPath(string configPath, out string siteID, out VirtualPath vpath) { if (!IsVirtualPathConfigPath(configPath)) { siteID = null; vpath = null; return; } int indexStart = RootWebConfigPath.Length + 1; int indexVPath = configPath.IndexOf(PathSeparator, indexStart); int length; if (indexVPath == -1) { length = configPath.Length - indexStart; } else { length = indexVPath - indexStart; } siteID = configPath.Substring(indexStart, length); if (indexVPath == -1) { vpath = VirtualPath.RootVirtualPath; } else { vpath = VirtualPath.CreateAbsolute(configPath.Substring(indexVPath)); } }
internal static void GetSiteIDAndVPathFromConfigPath(string configPath, out string siteID, out VirtualPath vpath) { if (!IsVirtualPathConfigPath(configPath)) { siteID = null; vpath = null; } else { int num3; int startIndex = "machine/webroot".Length + 1; int index = configPath.IndexOf('/', startIndex); if (index == -1) { num3 = configPath.Length - startIndex; } else { num3 = index - startIndex; } siteID = configPath.Substring(startIndex, num3); if (index == -1) { vpath = VirtualPath.RootVirtualPath; } else { vpath = VirtualPath.CreateAbsolute(configPath.Substring(index)); } } }
public override string GetConfigPathFromLocationSubPath(string configPath, string locationSubPath) { string str3; VirtualPath rootVirtualPath; if (IsVirtualPathConfigPath(configPath)) { return(CombineConfigPath(configPath, locationSubPath)); } string siteID = null; int index = locationSubPath.IndexOf('/'); if (index < 0) { str3 = locationSubPath; rootVirtualPath = VirtualPath.RootVirtualPath; } else { str3 = locationSubPath.Substring(0, index); rootVirtualPath = VirtualPath.CreateAbsolute(locationSubPath.Substring(index)); } if (System.Web.Util.StringUtil.EqualsIgnoreCase(str3, this._appSiteID) || System.Web.Util.StringUtil.EqualsIgnoreCase(str3, this._appSiteName)) { siteID = this._appSiteID; } else { siteID = str3; } return(GetConfigPathFromSiteIDAndVPath(siteID, rootVirtualPath)); }
public override string GetConfigPathFromLocationSubPath(string configPath, string locationSubPath) { #if DBG Debug.Assert(_inited, "_inited"); #endif string locationConfigPath; if (IsVirtualPathConfigPath(configPath)) { locationConfigPath = CombineConfigPath(configPath, locationSubPath); } else { string siteID = null; // First part of path is the site. // If it matches this app's site, use the proper site id, // otherwise just use the site as it is given, which will // result in it being ignored as desired. string site; VirtualPath virtualPath; int firstSlash = locationSubPath.IndexOf(PathSeparator); if (firstSlash < 0) { site = locationSubPath; virtualPath = VirtualPath.RootVirtualPath; } else { site = locationSubPath.Substring(0, firstSlash); virtualPath = VirtualPath.CreateAbsolute(locationSubPath.Substring(firstSlash)); } if (StringUtil.EqualsIgnoreCase(site, _appSiteID) || StringUtil.EqualsIgnoreCase(site, _appSiteName)) { siteID = _appSiteID; } else { siteID = site; } locationConfigPath = GetConfigPathFromSiteIDAndVPath(siteID, virtualPath); } return(locationConfigPath); }
private VirtualPath GetAppPathForPathWorker(string siteID, VirtualPath vpath) { string aboPath = this.GetAboPath(siteID, vpath.VirtualPathString); string str2 = this.MBGetAppPath(aboPath); if (str2 == null) { return(VirtualPath.RootVirtualPath); } string rootAppIDFromSiteID = this.GetRootAppIDFromSiteID(siteID); if (StringUtil.EqualsIgnoreCase(rootAppIDFromSiteID, str2)) { return(VirtualPath.RootVirtualPath); } return(VirtualPath.CreateAbsolute(str2.Substring(rootAppIDFromSiteID.Length))); }
internal void RemoveCookielessValuesFromPath() { string virtualPathString = this._Context.Request.ClientFilePath.VirtualPathString; if (virtualPathString.IndexOf('(') != -1) { int count = virtualPathString.LastIndexOf(")/", StringComparison.Ordinal); int length = (count > 2) ? virtualPathString.LastIndexOf("/(", count - 1, count, StringComparison.Ordinal) : -1; if (length >= 0) { if (this._Headers == null) { this.GetCookielessValuesFromHeader(); } if (IsValidHeader(virtualPathString, length + 2, count)) { if (this._Headers == null) { this._Headers = virtualPathString.Substring(length + 2, (count - length) - 2); } virtualPathString = virtualPathString.Substring(0, length) + virtualPathString.Substring(count + 1); this._Context.Request.ClientFilePath = VirtualPath.CreateAbsolute(virtualPathString); string rawUrl = this._Context.Request.RawUrl; int index = rawUrl.IndexOf('?'); if (index > -1) { virtualPathString = virtualPathString + rawUrl.Substring(index); } this._Context.Request.RawUrl = virtualPathString; if (!string.IsNullOrEmpty(this._Headers)) { this._Context.Request.ValidateCookielessHeaderIfRequiredByConfig(this._Headers); this._Context.Response.SetAppPathModifier("(" + this._Headers + ")"); string filePath = this._Context.Request.FilePath; string objB = this._Context.Response.RemoveAppPathModifier(filePath); if (!object.ReferenceEquals(filePath, objB)) { this._Context.RewritePath(VirtualPath.CreateAbsolute(objB), this._Context.Request.PathInfoObject, null, false); } } } } } }
VirtualPath GetAppPathForPathWorker(string siteID, VirtualPath vpath) { string aboPath = GetAboPath(siteID, vpath.VirtualPathString); string appAboPath = MBGetAppPath(aboPath); if (appAboPath == null) { return(VirtualPath.RootVirtualPath); } string rootAboPath = GetRootAppIDFromSiteID(siteID); if (StringUtil.EqualsIgnoreCase(rootAboPath, appAboPath)) { return(VirtualPath.RootVirtualPath); } string appPath = appAboPath.Substring(rootAboPath.Length); return(VirtualPath.CreateAbsolute(appPath)); }
// This function is called for all requests -- it must be performant. // In the common case (i.e. value not present in the URI, it must not // look at the headers collection internal void RemoveCookielessValuesFromPath() { // See if the path contains "/(XXXXX)/" string path = _Context.Request.ClientFilePath.VirtualPathString; // Optimize for the common case where there is no cookie if (path.IndexOf('(') == -1) { return; } int endPos = path.LastIndexOf(")/", StringComparison.Ordinal); int startPos = (endPos > 2 ? path.LastIndexOf("/(", endPos - 1, endPos, StringComparison.Ordinal) : -1); if (startPos < 0) // pattern not found: common case, exit immediately { return; } if (_Headers == null) // Header should always be processed first { GetCookielessValuesFromHeader(); } // if the path contains a cookie, remove it if (IsValidHeader(path, startPos + 2, endPos)) { // only set _Headers if not already set if (_Headers == null) { _Headers = path.Substring(startPos + 2, endPos - startPos - 2); } // Rewrite the path path = path.Substring(0, startPos) + path.Substring(endPos + 1); // remove cookie from ClientFilePath _Context.Request.ClientFilePath = VirtualPath.CreateAbsolute(path); // get and append query string to path if it exists string rawUrl = _Context.Request.RawUrl; int qsIndex = rawUrl.IndexOf('?'); if (qsIndex > -1) { path = path + rawUrl.Substring(qsIndex); } // remove cookie from RawUrl _Context.Request.RawUrl = path; if (!String.IsNullOrEmpty(_Headers)) { _Context.Request.ValidateCookielessHeaderIfRequiredByConfig(_Headers); // ensure that the path doesn't contain invalid chars _Context.Response.SetAppPathModifier("(" + _Headers + ")"); // For Cassini and scenarios where aspnet_filter.dll is not used, // HttpRequest.FilePath also needs to have the cookie removed. string filePath = _Context.Request.FilePath; string newFilePath = _Context.Response.RemoveAppPathModifier(filePath); if (!Object.ReferenceEquals(filePath, newFilePath)) { _Context.RewritePath(VirtualPath.CreateAbsolute(newFilePath), _Context.Request.PathInfoObject, null /*newQueryString*/, false /*setClientFilePath*/); } } } }