예제 #1
0
        /// <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);
        }
예제 #2
0
        /*
         * 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);
        }
예제 #3
0
        /*
         * internal HttpConfigurationRecord GetInitDefaultConfig() {
         *  return GetCompleteConfigRecord(_request.ApplicationPath, _wr);
         * }
         */

        /*
         * Uses the Config system to get the specified configuraiton
         */
        /// <include file='doc\HttpContext.uex' path='docs/doc[@for="HttpContext.GetConfig"]/*' />
        /// <devdoc>
        /// </devdoc>
        public Object GetConfig(String name)
        {
            Object config = null;

            HttpContext.ImpersonationSuspendContext ictx = Impersonation.SuspendIfClient();

            try {
                try {
                    config = GetCompleteConfig()[name];
                }
                finally {
                    ictx.Resume();
                }
            }
            catch { // Protect against exception filters
                throw;
            }

            return(config);
        }