internal BuildResultNoCompilePage(Type baseType, TemplateParser parser) : base(baseType, parser) { PageParser parser2 = (PageParser)parser; this._traceEnabled = parser2.TraceEnabled; this._traceMode = parser2.TraceMode; if (parser2.OutputCacheParameters != null) { this._outputCacheData = parser2.OutputCacheParameters; if ((this._outputCacheData.Duration == 0) || (this._outputCacheData.Location == OutputCacheLocation.None)) { this._outputCacheData = null; } else { this._fileDependencies = new string[parser2.SourceDependencies.Count]; int num = 0; foreach (string str in (IEnumerable)parser2.SourceDependencies) { this._fileDependencies[num++] = str; } } } this._validateRequest = parser2.ValidateRequest; this._stylesheetTheme = parser2.StyleSheetTheme; }
/// <include file='doc\TraceContext.uex' path='docs/doc[@for="TraceContext.TraceContext"]/*' /> /// <devdoc> /// <para>Initializes a new instance of the <see cref='System.Web.TraceContext'/> class.</para> /// </devdoc> public TraceContext(HttpContext context) { _traceMode = TraceMode.Default; _isEnabled = TraceEnable.Default; _context = context; _firstTime = -1; _lastTime = -1; _endDataCollected = false; }
/// <devdoc> /// <para>Initializes a new instance of the <see cref='System.Web.TraceContext'/> class.</para> /// </devdoc> public TraceContext(HttpContext context) { _traceMode = TraceMode.Default; // Always disable trace in retail deployment mode (DevDiv 36396) _isEnabled = DeploymentSection.RetailInternal ? TraceEnable.Disable : TraceEnable.Default; _context = context; _firstTime = -1; _lastTime = -1; _endDataCollected = false; _traceRecords = new ArrayList(); }
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); }
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 void Render(HtmlTextWriter output) { if (PageOutput && _requestData != null) { TraceEnable oldEnabled = _isEnabled; _isEnabled = TraceEnable.Disable; Control table; output.Write("<div id=\"__asptrace\">\r\n"); output.Write(TraceHandler.StyleSheet); output.Write("<span class=\"tracecontent\">\r\n"); table = TraceHandler.CreateDetailsTable(_requestData.Tables[SR.Trace_Request]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTraceTable(_requestData.Tables[SR.Trace_Trace_Information]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateControlTable(_requestData.Tables[SR.Trace_Control_Tree]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Session_State], true /*encodeSpaces*/); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Application_State], true /*encodeSpaces*/); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Request_Cookies_Collection], true /*encodeSpaces*/); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Response_Cookies_Collection], true /*encodeSpaces*/); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Headers_Collection], true /*encodeSpaces*/); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Response_Headers_Collection], true /*encodeSpaces*/); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Form_Collection]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Querystring_Collection]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Server_Variables], true /*encodeSpaces*/); if (table != null) { table.RenderControl(output); } output.Write("<hr width=100% size=1 color=silver>\r\n\r\n"); output.Write(SR.GetString(SR.Error_Formatter_CLR_Build) + VersionInfo.ClrVersion + SR.GetString(SR.Error_Formatter_ASPNET_Build) + VersionInfo.EngineVersion + "\r\n\r\n"); output.Write("</font>\r\n\r\n"); output.Write("</span>\r\n</div>\r\n"); _isEnabled = oldEnabled; } }
internal void Render(HtmlTextWriter output) { if (PageOutput && _requestData != null) { TraceEnable oldEnabled = _isEnabled; _isEnabled = TraceEnable.Disable; Control table; output.Write("<div id=\"__asptrace\">\r\n"); output.Write(TraceHandler.StyleSheet); output.Write("<span class=\"tracecontent\">\r\n"); table = TraceHandler.CreateDetailsTable(_requestData.Tables[SR.Trace_Request]); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTraceTable(_requestData.Tables[SR.Trace_Trace_Information]); if (table != null) table.RenderControl(output); table = TraceHandler.CreateControlTable(_requestData.Tables[SR.Trace_Control_Tree]); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Session_State], true /*encodeSpaces*/); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Application_State], true /*encodeSpaces*/); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Request_Cookies_Collection], true /*encodeSpaces*/); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Response_Cookies_Collection], true /*encodeSpaces*/); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Headers_Collection], true /*encodeSpaces*/); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Response_Headers_Collection], true /*encodeSpaces*/); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Form_Collection]); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Querystring_Collection]); if (table != null) table.RenderControl(output); table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Server_Variables], true /*encodeSpaces*/); if (table != null) table.RenderControl(output); output.Write("<hr width=100% size=1 color=silver>\r\n\r\n"); output.Write(SR.GetString(SR.Error_Formatter_CLR_Build) + VersionInfo.ClrVersion + SR.GetString(SR.Error_Formatter_ASPNET_Build) + VersionInfo.EngineVersion + "\r\n\r\n"); output.Write("</font>\r\n\r\n"); output.Write("</span>\r\n</div>\r\n"); _isEnabled = oldEnabled; } }
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; }
internal BuildResultNoCompilePage(Type baseType, TemplateParser parser) : base(baseType, parser) { PageParser pageParser = (PageParser) parser; // // Keep track of relevant info from the parser // _traceEnabled = pageParser.TraceEnabled; _traceMode = pageParser.TraceMode; if (pageParser.OutputCacheParameters != null) { _outputCacheData = pageParser.OutputCacheParameters; // If we're not supposed to cache it, clear out the field if (_outputCacheData.Duration == 0 || _outputCacheData.Location == OutputCacheLocation.None) { _outputCacheData = null; } else { // Since we're going to be output caching, remember all the dependencies _fileDependencies = new string[pageParser.SourceDependencies.Count]; int i = 0; foreach (string dependency in pageParser.SourceDependencies) { _fileDependencies[i++] = dependency; } Debug.Assert(i == pageParser.SourceDependencies.Count); } } _validateRequest = pageParser.ValidateRequest; _stylesheetTheme = pageParser.StyleSheetTheme; }
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 void Render(HtmlTextWriter output) { if (this.PageOutput && (this._requestData != null)) { TraceEnable enable = this._isEnabled; this._isEnabled = TraceEnable.Disable; output.Write("<div id=\"__asptrace\">\r\n"); output.Write(TraceHandler.StyleSheet); output.Write("<span class=\"tracecontent\">\r\n"); Control control = TraceHandler.CreateDetailsTable(this._requestData.Tables["Trace_Request"]); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTraceTable(this._requestData.Tables["Trace_Trace_Information"]); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateControlTable(this._requestData.Tables["Trace_Control_Tree"]); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Session_State"], true); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Application_State"], true); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Request_Cookies_Collection"], true); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Response_Cookies_Collection"], true); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Headers_Collection"], true); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Response_Headers_Collection"], true); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Form_Collection"]); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Querystring_Collection"]); if (control != null) { control.RenderControl(output); } control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Server_Variables"], true); if (control != null) { control.RenderControl(output); } output.Write("<hr width=100% size=1 color=silver>\r\n\r\n"); output.Write(System.Web.SR.GetString("Error_Formatter_CLR_Build") + VersionInfo.ClrVersion + System.Web.SR.GetString("Error_Formatter_ASPNET_Build") + VersionInfo.EngineVersion + "\r\n\r\n"); output.Write("</font>\r\n\r\n"); output.Write("</span>\r\n</div>\r\n"); this._isEnabled = enable; } }
internal void Render(HtmlTextWriter output) { if (PageOutput && _requestData != null) { TraceEnable oldEnabled = _isEnabled; _isEnabled = TraceEnable.Disable; Control table; output.Write("<div id=\"__asptrace\">\r\n"); output.Write(TraceHandler.StyleSheet); output.Write("<span class=\"tracecontent\">\r\n"); table = TraceHandler.CreateDetailsTable(_requestData.Tables[SR.Trace_Request]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTraceTable(_requestData.Tables[SR.Trace_Trace_Information]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateControlTable(_requestData.Tables[SR.Trace_Control_Tree]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Session_State]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Application_State]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Cookies_Collection]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Headers_Collection]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Form_Collection]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Querystring_Collection]); if (table != null) { table.RenderControl(output); } table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Server_Variables]); if (table != null) { table.RenderControl(output); } output.Write("</span>\r\n</div>\r\n"); _isEnabled = oldEnabled; } }
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); }