/*
         * Return a CompilerInfo that a language maps to.
         */
        internal CompilerInfo GetCompilerInfoFromLanguage(string language)
        {
            CompilerInfo compilerInfo = (CompilerInfo)CompilerLanguages[language];

            if (compilerInfo == null)
            {
                // Unsupported language: throw an exception
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Invalid_lang, language));
            }

            // Only allow the use of compilerOptions when we have UnmanagedCode access (ASURT 73678)
            if (compilerInfo.CompilParams.CompilerOptions != null)
            {
                if (!HttpRuntime.HasUnmanagedPermission())
                {
                    throw new ConfigurationException(
                              HttpRuntime.FormatResourceString(SR.Insufficient_trust_for_attribute, "compilerOptions"),
                              compilerInfo.ConfigFileName, compilerInfo.ConfigFileLineNumber);
                }
            }

            // Clone it so the original is not modified
            compilerInfo = compilerInfo.Clone();

            // Set the value of the debug flag in the copy
            compilerInfo.CompilParams.IncludeDebugInformation = _debug;

            return(compilerInfo);
        }
Exemplo n.º 2
0
        protected internal override void Render(HtmlTextWriter output)
        {
            // If we don't already have an XmlDocument or an XPathNavigator, load am XPathDocument (which is faster)
            if ((_document == null) && (_xpathNavigator == null))
            {
                LoadXPathDocument();
            }

            LoadTransformFromSource();

            // Abort if nothing has been loaded
            if (_document == null && _xpathDocument == null && _xpathNavigator == null)
            {
                return;
            }

            // If we don't have a transform, use the identity transform, which
            // simply renders the XML.
            if (_transform == null)
            {
                _transform = _identityTransform;
            }

            // Pass a resolver in full trust, to support certain XSL scenarios (ASURT 141427)
            XmlUrlResolver xr = null;

            if (HttpRuntime.HasUnmanagedPermission())
            {
                xr = new XmlUrlResolver();
            }

            IXPathNavigable doc = null;

            if (_document != null)
            {
                doc = _document;
            }
            else if (_xpathNavigator != null)
            {
                doc = _xpathNavigator;
            }
            else
            {
                doc = _xpathDocument;
            }

            if (_compiledTransform != null)
            {
                XmlWriter writer = XmlWriter.Create(output);
                _compiledTransform.Transform(doc, _transformArgumentList, writer, null);
            }
            else
            {
                _transform.Transform(doc, _transformArgumentList, output, xr);
            }
        }
Exemplo n.º 3
0
 internal static void CheckCompilerOptionsAllowed(string compilerOptions, bool config, string file, int line)
 {
     if (!string.IsNullOrEmpty(compilerOptions) && !HttpRuntime.HasUnmanagedPermission())
     {
         string message = System.Web.SR.GetString("Insufficient_trust_for_attribute", new object[] { "compilerOptions" });
         if (config)
         {
             throw new ConfigurationErrorsException(message, file, line);
         }
         throw new HttpException(message);
     }
 }
Exemplo n.º 4
0
        // In partial trust, do not allow the CompilerDirectoryPath provider option in codedom settings (Dev10
        internal static void CheckCompilerDirectoryPathAllowed(IDictionary <string, string> providerOptions)
        {
            if (providerOptions == null)
            {
                return;
            }
            if (!providerOptions.ContainsKey(CompilerDirectoryPath))
            {
                return;
            }

            if (!HttpRuntime.HasUnmanagedPermission())
            {
                string errorString = SR.GetString(SR.Insufficient_trust_for_attribute, CompilerDirectoryPath);
                throw new HttpException(errorString);
            }
        }
Exemplo n.º 5
0
 protected internal override void Render(HtmlTextWriter output)
 {
     if ((this._document == null) && (this._xpathNavigator == null))
     {
         this.LoadXPathDocument();
     }
     this.LoadTransformFromSource();
     if (((this._document != null) || (this._xpathDocument != null)) || (this._xpathNavigator != null))
     {
         if (this._transform == null)
         {
             this._transform = _identityTransform;
         }
         XmlUrlResolver resolver = null;
         if (HttpRuntime.HasUnmanagedPermission())
         {
             resolver = new XmlUrlResolver();
         }
         IXPathNavigable input = null;
         if (this._document != null)
         {
             input = this._document;
         }
         else if (this._xpathNavigator != null)
         {
             input = this._xpathNavigator;
         }
         else
         {
             input = this._xpathDocument;
         }
         if (AppSettings.RestrictXmlControls && (this._compiledTransform != null))
         {
             this._compiledTransform.Transform(input, this._transformArgumentList, output);
         }
         else
         {
             this._transform.Transform(input, this._transformArgumentList, (TextWriter)output, resolver);
         }
     }
 }
        private static void ProcessCompilationParams(IDictionary directive, CompilerParameters compilParams)
        {
            bool fDebug = false;

            if (Util.GetAndRemoveBooleanAttribute(directive, "debug", ref fDebug))
            {
                compilParams.IncludeDebugInformation = fDebug;
            }

            if (compilParams.IncludeDebugInformation &&
                !HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium))
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Insufficient_trust_for_attribute, "debug"));
            }

            int warningLevel = 0;

            if (Util.GetAndRemoveNonNegativeIntegerAttribute(directive, "warninglevel", ref warningLevel))
            {
                compilParams.WarningLevel = warningLevel;
                if (warningLevel > 0)
                {
                    compilParams.TreatWarningsAsErrors = true;
                }
            }

            string compilerOptions = Util.GetAndRemoveNonEmptyAttribute(
                directive, "compileroptions");

            if (compilerOptions != null)
            {
                // Only allow the use of compilerOptions when we have UnmanagedCode access (ASURT 73678)
                if (!HttpRuntime.HasUnmanagedPermission())
                {
                    throw new HttpException(HttpRuntime.FormatResourceString(SR.Insufficient_trust_for_attribute, "CompilerOptions"));
                }

                compilParams.CompilerOptions = compilerOptions;
            }
        }
Exemplo n.º 7
0
        /// <include file='doc\xml.uex' path='docs/doc[@for="Xml.Render"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected override void Render(HtmlTextWriter output)
        {
            // If we don't already have an XmlDocument, load am XPathDocument (which is faster)
            if (_document == null)
            {
                LoadXPathDocument();
            }

            LoadTransformFromSource();

            if (_document == null && _xpathDocument == null)
            {
                return;
            }

            // If we don't have a transform, use the identity transform, which
            // simply renders the XML.
            if (_transform == null)
            {
                _transform = _identityTransform;
            }

            // Pass a resolver in full trust, to support certain XSL scenarios (ASURT 141427)
            XmlUrlResolver xr = null;

            if (HttpRuntime.HasUnmanagedPermission())
            {
                xr = new XmlUrlResolver();
            }

            if (_document != null)
            {
                Transform.Transform(_document, _transformArgumentList, output, xr);
            }
            else
            {
                Transform.Transform(_xpathDocument, _transformArgumentList, output, xr);
            }
        }
Exemplo n.º 8
0
        internal static void CheckCompilerOptionsAllowed(string compilerOptions, bool config, string file, int line)
        {
            // If it's empty, we never block it
            if (String.IsNullOrEmpty(compilerOptions))
            {
                return;
            }

            // Only allow the use of compilerOptions when we have UnmanagedCode access (ASURT 73678)
            if (!HttpRuntime.HasUnmanagedPermission())
            {
                string errorString = SR.GetString(SR.Insufficient_trust_for_attribute, "compilerOptions");

                if (config)
                {
                    throw new ConfigurationErrorsException(errorString, file, line);
                }
                else
                {
                    throw new HttpException(errorString);
                }
            }
        }
        internal override bool ProcessMainDirectiveAttribute(string deviceName, string name, string value, IDictionary parseData)
        {
            switch (name)
            {
            case "errorpage":
                this._errorPage = System.Web.UI.Util.GetNonEmptyAttribute(name, value);
                return(false);

            case "contenttype":
                System.Web.UI.Util.GetNonEmptyAttribute(name, value);
                return(false);

            case "theme":
                if (!base.IsExpressionBuilderValue(value))
                {
                    System.Web.UI.Util.CheckThemeAttribute(value);
                    return(false);
                }
                return(false);

            case "stylesheettheme":
                base.ValidateBuiltInAttribute(deviceName, name, value);
                System.Web.UI.Util.CheckThemeAttribute(value);
                this._styleSheetTheme = value;
                return(true);

            case "enablesessionstate":
                this.flags[0x100000] = true;
                this.flags[0x200000] = false;
                if (!System.Web.UI.Util.IsFalseString(value))
                {
                    if (StringUtil.EqualsIgnoreCase(value, "readonly"))
                    {
                        this.flags[0x200000] = true;
                    }
                    else if (!System.Web.UI.Util.IsTrueString(value))
                    {
                        base.ProcessError(System.Web.SR.GetString("Enablesessionstate_must_be_true_false_or_readonly"));
                    }
                    break;
                }
                this.flags[0x100000] = false;
                break;

            case "culture":
                this._culture = System.Web.UI.Util.GetNonEmptyAttribute(name, value);
                if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium))
                {
                    throw new HttpException(System.Web.SR.GetString("Insufficient_trust_for_attribute", new object[] { "culture" }));
                }
                if (!StringUtil.EqualsIgnoreCase(value, HttpApplication.AutoCulture))
                {
                    CultureInfo info;
                    try
                    {
                        if (StringUtil.StringStartsWithIgnoreCase(value, HttpApplication.AutoCulture))
                        {
                            this._culture = this._culture.Substring(5);
                        }
                        info = HttpServerUtility.CreateReadOnlyCultureInfo(this._culture);
                    }
                    catch
                    {
                        base.ProcessError(System.Web.SR.GetString("Invalid_attribute_value", new object[] { this._culture, "culture" }));
                        return(false);
                    }
                    if (info.IsNeutralCulture)
                    {
                        base.ProcessError(System.Web.SR.GetString("Invalid_culture_attribute", new object[] { System.Web.UI.Util.GetSpecificCulturesFormattedList(info) }));
                    }
                }
                return(false);

            case "lcid":
                if (!base.IsExpressionBuilderValue(value))
                {
                    this._lcid = System.Web.UI.Util.GetNonNegativeIntegerAttribute(name, value);
                    try
                    {
                        HttpServerUtility.CreateReadOnlyCultureInfo(this._lcid);
                    }
                    catch
                    {
                        base.ProcessError(System.Web.SR.GetString("Invalid_attribute_value", new object[] { this._lcid.ToString(CultureInfo.InvariantCulture), "lcid" }));
                    }
                    return(false);
                }
                return(false);

            case "uiculture":
                System.Web.UI.Util.GetNonEmptyAttribute(name, value);
                return(false);

            case "responseencoding":
                if (!base.IsExpressionBuilderValue(value))
                {
                    this._responseEncoding = System.Web.UI.Util.GetNonEmptyAttribute(name, value);
                    Encoding.GetEncoding(this._responseEncoding);
                    return(false);
                }
                return(false);

            case "codepage":
                if (!base.IsExpressionBuilderValue(value))
                {
                    this._codePage = System.Web.UI.Util.GetNonNegativeIntegerAttribute(name, value);
                    Encoding.GetEncoding(this._codePage);
                    return(false);
                }
                return(false);

            case "transaction":
                base.OnFoundAttributeRequiringCompilation(name);
                this.ParseTransactionAttribute(name, value);
                goto Label_05CF;

            case "aspcompat":
                base.OnFoundAttributeRequiringCompilation(name);
                this.flags[0x40] = System.Web.UI.Util.GetBooleanAttribute(name, value);
                if (this.flags[0x40] && !HttpRuntime.HasUnmanagedPermission())
                {
                    throw new HttpException(System.Web.SR.GetString("Insufficient_trust_for_attribute", new object[] { "AspCompat" }));
                }
                goto Label_05CF;

            case "async":
                base.OnFoundAttributeRequiringCompilation(name);
                this.flags[0x800000] = System.Web.UI.Util.GetBooleanAttribute(name, value);
                if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium))
                {
                    throw new HttpException(System.Web.SR.GetString("Insufficient_trust_for_attribute", new object[] { "async" }));
                }
                goto Label_05CF;

            case "tracemode":
            {
                object obj2 = System.Web.UI.Util.GetEnumAttribute(name, value, typeof(TraceModeInternal));
                this._traceMode = (System.Web.TraceMode)obj2;
                goto Label_05CF;
            }

            case "trace":
                if (!System.Web.UI.Util.GetBooleanAttribute(name, value))
                {
                    this._traceEnabled = TraceEnable.Disable;
                }
                else
                {
                    this._traceEnabled = TraceEnable.Enable;
                }
                goto Label_05CF;

            case "smartnavigation":
                base.ValidateBuiltInAttribute(deviceName, name, value);
                return(!System.Web.UI.Util.GetBooleanAttribute(name, value));

            case "maintainscrollpositiononpostback":
                return(!System.Web.UI.Util.GetBooleanAttribute(name, value));

            case "validaterequest":
                this.flags[0x400000] = System.Web.UI.Util.GetBooleanAttribute(name, value);
                goto Label_05CF;

            case "clienttarget":
                if (!base.IsExpressionBuilderValue(value))
                {
                    HttpCapabilitiesDefaultProvider.GetUserAgentFromClientTarget(base.CurrentVirtualPath, value);
                    return(false);
                }
                return(false);

            case "masterpagefile":
                if (!base.IsExpressionBuilderValue(value))
                {
                    if (value.Length > 0)
                    {
                        Type referencedType = base.GetReferencedType(value);
                        if (!typeof(MasterPage).IsAssignableFrom(referencedType))
                        {
                            base.ProcessError(System.Web.SR.GetString("Invalid_master_base", new object[] { value }));
                        }
                        if (deviceName.Length > 0)
                        {
                            this.EnsureMasterPageFileFromConfigApplied();
                        }
                    }
                    this._mainDirectiveMasterPageSet = true;
                    return(false);
                }
                return(false);

            default:
                return(base.ProcessMainDirectiveAttribute(deviceName, name, value, parseData));
            }
            if (this.flags[0x100000])
            {
                base.OnFoundAttributeRequiringCompilation(name);
            }
Label_05CF:
            base.ValidateBuiltInAttribute(deviceName, name, value);
            return(true);
        }
Exemplo n.º 10
0
        internal override bool ProcessMainDirectiveAttribute(string deviceName, string name,
                                                             string value, IDictionary parseData)
        {
            switch (name)
            {
            case "errorpage":
                _errorPage = Util.GetNonEmptyAttribute(name, value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "contenttype":
                // Check validity
                Util.GetNonEmptyAttribute(name, value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "theme":
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                // Check validity
                Util.CheckThemeAttribute(value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "stylesheettheme":
                // Make sure no device filter or expression builder was specified
                ValidateBuiltInAttribute(deviceName, name, value);

                // Check validity
                Util.CheckThemeAttribute(value);

                _styleSheetTheme = value;
                return(true);

            case "enablesessionstate":
                flags[requiresSessionState] = true;
                flags[readOnlySessionState] = false;
                if (Util.IsFalseString(value))
                {
                    flags[requiresSessionState] = false;
                }
                else if (StringUtil.EqualsIgnoreCase(value, "readonly"))
                {
                    flags[readOnlySessionState] = true;
                }
                else if (!Util.IsTrueString(value))
                {
                    ProcessError(SR.GetString(SR.Enablesessionstate_must_be_true_false_or_readonly));
                }

                if (flags[requiresSessionState])
                {
                    // Session state is only available for compiled pages
                    OnFoundAttributeRequiringCompilation(name);
                }
                break;

            case "culture":
                _culture = Util.GetNonEmptyAttribute(name, value);

                // Setting culture requires medium permission
                if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium))
                {
                    throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "culture"));
                }

                //do not verify at parse time if potentially using browser AutoDetect
                if (StringUtil.EqualsIgnoreCase(value, HttpApplication.AutoCulture))
                {
                    return(false);
                }


                // Create a CultureInfo just to verify validity
                CultureInfo cultureInfo;

                try {
                    if (StringUtil.StringStartsWithIgnoreCase(value, HttpApplication.AutoCulture))
                    {
                        //safe to trim leading "auto:", string used elsewhere for null check
                        _culture = _culture.Substring(5);
                    }
                    cultureInfo = HttpServerUtility.CreateReadOnlyCultureInfo(_culture);
                }
                catch {
                    ProcessError(SR.GetString(SR.Invalid_attribute_value, _culture, "culture"));
                    return(false);
                }

                // Don't allow neutral cultures (ASURT 77930)
                if (cultureInfo.IsNeutralCulture)
                {
                    ProcessError(SR.GetString(SR.Invalid_culture_attribute,
                                              Util.GetSpecificCulturesFormattedList(cultureInfo)));
                }

                // Return false to let the generic attribute processing continue
                return(false);

            case "lcid":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                _lcid = Util.GetNonNegativeIntegerAttribute(name, value);

                // Create a CultureInfo just to verify validity
                try {
                    HttpServerUtility.CreateReadOnlyCultureInfo(_lcid);
                }
                catch {
                    ProcessError(SR.GetString(SR.Invalid_attribute_value,
                                              _lcid.ToString(CultureInfo.InvariantCulture), "lcid"));
                }

                // Return false to let the generic attribute processing continue
                return(false);

            case "uiculture":
                // Check validity
                Util.GetNonEmptyAttribute(name, value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "responseencoding":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                _responseEncoding = Util.GetNonEmptyAttribute(name, value);

                // Call Encoding.GetEncoding just to verify validity
                Encoding.GetEncoding(_responseEncoding);

                // Return false to let the generic attribute processing continue
                return(false);

            case "codepage":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                _codePage = Util.GetNonNegativeIntegerAttribute(name, value);

                // Call Encoding.GetEncoding just to verify validity
                Encoding.GetEncoding(_codePage);

                // Return false to let the generic attribute processing continue
                return(false);

            case "transaction":
                // This only makes sense for compiled pages
                OnFoundAttributeRequiringCompilation(name);

                ParseTransactionAttribute(name, value);
                break;

            case "aspcompat":
                // This only makes sense for compiled pages
                OnFoundAttributeRequiringCompilation(name);

                flags[aspCompatMode] = Util.GetBooleanAttribute(name, value);

                // Only allow the use of aspcompat when we have UnmanagedCode access (ASURT 76694)
                if (flags[aspCompatMode] && !HttpRuntime.HasUnmanagedPermission())
                {
                    throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "AspCompat"));
                }

                break;

            case "async":
                // This only makes sense for compiled pages
                OnFoundAttributeRequiringCompilation(name);

                flags[asyncMode] = Util.GetBooleanAttribute(name, value);

                // Async requires Medium trust
                if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium))
                {
                    throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "async"));
                }

                break;

            case "tracemode":
                // We use TraceModeInternal instead of TraceMode to disallow the 'default' value (ASURT 75783)
                object tmpObj = Util.GetEnumAttribute(name, value, typeof(TraceModeInternal));
                _traceMode = (TraceMode)tmpObj;
                break;

            case "trace":
                bool traceEnabled = Util.GetBooleanAttribute(name, value);
                if (traceEnabled)
                {
                    _traceEnabled = TraceEnable.Enable;
                }
                else
                {
                    _traceEnabled = TraceEnable.Disable;
                }
                break;

            case "smartnavigation":
                // Make sure no device filter or expression builder was specified, since it doesn't make much
                // sense for smartnav (which only works on IE5.5+) (VSWhidbey 85876)
                ValidateBuiltInAttribute(deviceName, name, value);

                // Ignore it if it has default value.  Otherwise, let the generic
                // attribute processing continue
                bool smartNavigation = Util.GetBooleanAttribute(name, value);
                return(smartNavigation == Page.SmartNavigationDefault);

            case "maintainscrollpositiononpostback":
                bool maintainScrollPosition = Util.GetBooleanAttribute(name, value);
                return(maintainScrollPosition == Page.MaintainScrollPositionOnPostBackDefault);

            case "validaterequest":
                flags[validateRequest] = Util.GetBooleanAttribute(name, value);
                break;

            case "clienttarget":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                // Check validity
                HttpCapabilitiesDefaultProvider.GetUserAgentFromClientTarget(CurrentVirtualPath, value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "masterpagefile":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                if (value.Length > 0)
                {
                    // Add dependency on the Type by calling this method
                    Type type = GetReferencedType(value);

                    // Make sure it has the correct base type
                    if (!typeof(MasterPage).IsAssignableFrom(type))
                    {
                        ProcessError(SR.GetString(SR.Invalid_master_base, value));
                    }

                    if (deviceName.Length > 0)
                    {
                        // Make sure the masterPageFile definition from config
                        // is applied before filtered masterPageFile attributes.
                        EnsureMasterPageFileFromConfigApplied();
                    }
                }

                //VSWhidbey 479064 Remember the masterPageFile had been set even if it's empty string
                _mainDirectiveMasterPageSet = true;

                // Return false to let the generic attribute processing continue
                return(false);

            default:
                // We didn't handle the attribute.  Try the base class
                return(base.ProcessMainDirectiveAttribute(deviceName, name, value, parseData));
            }

            // The attribute was handled

            // Make sure no device filter or resource expression was specified
            ValidateBuiltInAttribute(deviceName, name, value);

            return(true);
        }
 internal SqlExpressConnectionErrorFormatter(DataConnectionErrorEnum error)
 {
     _UserName = (HttpRuntime.HasUnmanagedPermission() ? DataConnectionHelper.GetCurrentName() : String.Empty);
     _Error    = error;
 }
Exemplo n.º 12
0
 internal static void CheckCompilerDirectoryPathAllowed(IDictionary <string, string> providerOptions)
 {
     if (((providerOptions != null) && providerOptions.ContainsKey("CompilerDirectoryPath")) && !HttpRuntime.HasUnmanagedPermission())
     {
         throw new HttpException(System.Web.SR.GetString("Insufficient_trust_for_attribute", new object[] { "CompilerDirectoryPath" }));
     }
 }
Exemplo n.º 13
0
        internal override void ProcessMainDirective(IDictionary mainDirective)
        {
            // Get the error page (if any).
            _errorPage = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "errorpage");

            // Get various attributes

            _clientTarget = Util.GetAndRemove(mainDirective, "clienttarget");

            _contentType = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "contenttype");

            Util.GetAndRemoveBooleanAttribute(mainDirective, "buffer",
                                              ref _fBuffer);

            if (!_fBuffer && _errorPage != null)
            {
                throw new HttpException(
                          HttpRuntime.FormatResourceString(SR.Error_page_not_supported_when_buffering_off));
            }

            string tmp = Util.GetAndRemove(mainDirective, "enablesessionstate");

            if (tmp != null)
            {
                _fRequiresSessionState = true;
                _fReadOnlySessionState = false;
                if (Util.IsFalseString(tmp))
                {
                    _fRequiresSessionState = false;
                }
                else if (string.Compare(tmp, "readonly", true, CultureInfo.InvariantCulture) == 0)
                {
                    _fReadOnlySessionState = true;
                }
                else if (!Util.IsTrueString(tmp))
                {
                    throw new HttpException(
                              HttpRuntime.FormatResourceString(SR.Enablesessionstate_must_be_true_false_or_readonly));
                }
            }

            _culture = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "culture");

            // If it was specified, create a CultureInfo just to verify validity
            if (_culture != null)
            {
                CultureInfo cultureInfo;

                try {
                    cultureInfo = HttpServerUtility.CreateReadOnlyCultureInfo(_culture);
                }
                catch {
                    throw new HttpException(
                              HttpRuntime.FormatResourceString(SR.Invalid_attribute_value, _culture, "culture"));
                }

                // Don't allow neutral cultures (ASURT 77930)
                if (cultureInfo.IsNeutralCulture)
                {
                    throw new HttpException(
                              HttpRuntime.FormatResourceString(SR.Invalid_culture_attribute,
                                                               Util.GetSpecificCulturesFormattedList(cultureInfo)));
                }
            }

            bool fHasLcid = Util.GetAndRemoveNonNegativeIntegerAttribute(mainDirective, "lcid", ref _lcid);

            // If it was specified, create a CultureInfo just to verify validity
            if (fHasLcid)
            {
                try {
                    HttpServerUtility.CreateReadOnlyCultureInfo(_lcid);
                }
                catch {
                    throw new HttpException(
                              HttpRuntime.FormatResourceString(SR.Invalid_attribute_value, _lcid.ToString(), "lcid"));
                }
            }

            if (_culture != null && fHasLcid)
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Attributes_mutually_exclusive, "Culture", "LCID"));
            }

            _uiCulture = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "uiculture");

            _responseEncoding = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "responseencoding");
            // If it was specified, call Encoding.GetEncoding just to verify validity
            if (_responseEncoding != null)
            {
                Encoding.GetEncoding(_responseEncoding);
            }

            bool fHasCodePage = Util.GetAndRemoveNonNegativeIntegerAttribute(mainDirective, "codepage", ref _codePage);

            // If it was specified, call Encoding.GetEncoding just to verify validity
            if (fHasCodePage)
            {
                Encoding.GetEncoding(_codePage);
            }

            if (_responseEncoding != null && fHasCodePage)
            {
                throw new HttpException(
                          HttpRuntime.FormatResourceString(SR.Attributes_mutually_exclusive, "ResponseEncoding", "CodePage"));
            }

            if (mainDirective["transaction"] != null)
            {
                ParseTransactionAttribute(mainDirective);
            }

            if (Util.GetAndRemoveBooleanAttribute(mainDirective, "aspcompat", ref _aspCompatMode))
            {
                // Only allow the use of aspcompat when we have UnmanagedCode access (ASURT 76694)
                if (_aspCompatMode && !HttpRuntime.HasUnmanagedPermission())
                {
                    throw new HttpException(HttpRuntime.FormatResourceString(SR.Insufficient_trust_for_attribute, "AspCompat"));
                }
            }

            // We use TraceModeInternal instead of TraceMode to disallow the 'default' value (ASURT 75783)
            object tmpObj = Util.GetAndRemoveEnumAttribute(
                mainDirective, typeof(TraceModeInternal), "tracemode");

            if (tmpObj != null)
            {
                _traceMode = (TraceMode)tmpObj;
            }

            bool traceEnabled = false;

            if (Util.GetAndRemoveBooleanAttribute(mainDirective, "trace", ref traceEnabled))
            {
                if (traceEnabled)
                {
                    _traceEnabled = TraceEnable.Enable;
                }
                else
                {
                    _traceEnabled = TraceEnable.Disable;
                }
            }

            Util.GetAndRemoveBooleanAttribute(mainDirective, "enableviewstatemac", ref _enableViewStateMac);

            Util.GetAndRemoveBooleanAttribute(mainDirective, "smartnavigation", ref _smartNavigation);

            Util.GetAndRemoveBooleanAttribute(mainDirective, "validaterequest", ref _validateRequest);

            base.ProcessMainDirective(mainDirective);
        }