/*internal String MachineConfigPath { * get { * if (_wr == null) * throw new HttpException(HttpRuntime.FormatResourceString(SR.Cannot_get_config_dir)); * * return _wr.MachineConfigPath; * } * }*/ /* * Called by the URL rewrite module to modify the path for downstream modules */ /// <include file='doc\HttpContext.uex' path='docs/doc[@for="HttpContext.RewritePath"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void RewritePath(String path) { // extract query string String qs = null; int iqs = path.IndexOf('?'); if (iqs >= 0) { qs = (iqs < path.Length - 1) ? path.Substring(iqs + 1) : String.Empty; path = path.Substring(0, iqs); } // resolve relative path path = UrlPath.Combine(Request.BaseDir, path); // disallow paths outside of app if (!HttpRuntime.IsPathWithinAppRoot(path)) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Cross_app_not_allowed, path)); } // clear things that depend on path ConfigPath = null; // rewrite path on request Request.InternalRewritePath(path, qs); }
/* * Uses the Config system to get the specified configuraiton * * The following method is the only accessors to the config system, * and it wraps config exceptions with an explanatory HTTP * exception with an error formatter. It also makes sure the client * is not impersonated while accessing the config system. */ private HttpConfigurationRecord GetCompleteConfigRecord(String reqpath, IHttpMapPath configmap) { HttpConfigurationRecord configrecord = null; HttpContext.ImpersonationSuspendContext ictx = Impersonation.SuspendIfClient(); try { try { if (reqpath == null || reqpath.Length == 0 || HttpRuntime.IsPathWithinAppRoot(reqpath)) { // lookup by path using (new HttpContextWrapper(this)) { configrecord = HttpConfigurationSystem.GetComplete(reqpath, _wr); } } else { // if the path is outside of the application (and not site or machine) // then use application config configrecord = HttpConfigurationSystem.GetCompleteForApp(); } } finally { ictx.Resume(); } } catch { // Protect against exception filters throw; } return(configrecord); }
/// <include file='doc\HttpContext.uex' path='docs/doc[@for="HttpContext.RewritePath1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void RewritePath(String filePath, String pathInfo, String queryString) { // resolve relative path filePath = UrlPath.Combine(Request.BaseDir, filePath); // disallow paths outside of app if (!HttpRuntime.IsPathWithinAppRoot(filePath)) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Cross_app_not_allowed, filePath)); } // patch pathInfo if (pathInfo == null) { pathInfo = String.Empty; } // clear things that depend on path ConfigPath = null; // rewrite path on request Request.InternalRewritePath(filePath, pathInfo, queryString); }