/// <include file='doc\HttpContext.uex' path='docs/doc[@for="HttpContext.GetAppConfig"]/*' /> public static Object GetAppConfig(String name) { HttpContext context = HttpContext.Current; HttpContext.ImpersonationSuspendContext ictx = null; if (context != null) { ictx = context.Impersonation.SuspendIfClient(); } try { try { HttpConfigurationRecord configRecord = HttpConfigurationSystem.GetCompleteForApp(); if (configRecord != null) { return(configRecord[name]); } } finally { if (ictx != null) { ictx.Resume(); } } } catch { throw; } return(null); }
/* * 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); }
static StateRuntime() { WebConfigurationFileMap fileMap = new WebConfigurationFileMap(); UserMapPath configMapPath = new UserMapPath(fileMap); HttpConfigurationSystem.EnsureInit(configMapPath, false, true); StateApplication customApplication = new StateApplication(); HttpApplicationFactory.SetCustomApplication(customApplication); PerfCounters.OpenStateCounters(); ResetStateServerCounters(); }
private void Init(CachedPathData parentData) { if (!HttpConfigurationSystem.UseHttpConfigurationSystem) { this._runtimeConfig = null; } else { IInternalConfigRecord uniqueConfigRecord = HttpConfigurationSystem.GetUniqueConfigRecord(this._configPath); if (uniqueConfigRecord.ConfigPath.Length == this._configPath.Length) { this._flags[0x10] = true; this._runtimeConfig = new System.Web.Configuration.RuntimeConfig(uniqueConfigRecord); } else { this._runtimeConfig = parentData._runtimeConfig; } } }
// Initialize the data void Init(CachedPathData parentData) { // Note that _runtimeConfig will be set to the singleton instance of ErrorRuntimeConfig // if a ThreadAbortException is thrown during this method. Debug.Assert(_runtimeConfig == RuntimeConfig.GetErrorRuntimeConfig(), "_runtimeConfig == RuntimeConfig.GetErrorRuntimeConfig()"); if (!HttpConfigurationSystem.UseHttpConfigurationSystem) { // // configRecord may legitimately be null if we are not using the HttpConfigurationSystem. // _runtimeConfig = null; } else { IInternalConfigRecord configRecord = HttpConfigurationSystem.GetUniqueConfigRecord(_configPath); Debug.Assert(configRecord != null, "configRecord != null"); if (configRecord.ConfigPath.Length == _configPath.Length) { // // The config is unique to this path, so this make this record the owner of the config. // _flags[FOwnsConfigRecord] = true; _runtimeConfig = new RuntimeConfig(configRecord); } else { // // The config record is the same as an ancestor's, so use the parent's RuntimeConfig. // Debug.Assert(parentData != null, "parentData != null"); _runtimeConfig = parentData._runtimeConfig; } } }
/* * Returns an array of filenames who are dependancies of the given path. */ internal string[] GetConfigurationDependencies(String reqpath) { return(HttpConfigurationSystem.GetConfigurationDependencies(reqpath, _wr)); }