2009-04-21 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Tue, 21 Apr 2009 17:54:02 +0000 (17:54 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Tue, 21 Apr 2009 17:54:02 +0000 (17:54 -0000)
* SimpleWebHandlerParser.cs: retrieve CompilationSection from the
appropriate web.config file.

* BaseParser.cs: moved the internal property VirtualPath from
TemplateParser to here and added an internal method
GetConfigSection to retrieve sections from the correct web.config
file on 2.0 applications. Fixes bug #494245

* PageParser.cs: use the new GetConfigSection method to retrieve
ClientTargetSection.

* TemplateParser.cs: moved the VirtualPath property to
BaseParser.
PagesConfig now uses the new GetConfigSection method. Fixes bug
#494245

svn path=/trunk/mcs/; revision=132300

mcs/class/System.Web/System.Web.UI/BaseParser.cs
mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/PageParser.cs
mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs
mcs/class/System.Web/System.Web.UI/TemplateParser.cs

index a1c04486c5c77b4f219cb6748941d8e85ecd2d1a..ecca9483538a475938ef3b7880ce20f941db9b7c 100644 (file)
@@ -151,10 +151,23 @@ namespace System.Web.UI
                }
 
 #if NET_2_0
+               internal TSection GetConfigSection <TSection> (string section) where TSection: global::System.Configuration.ConfigurationSection
+               {
+                       VirtualPath vpath = VirtualPath;
+                       string vp = vpath != null ? vpath.Absolute : null;
+                       if (vp == null)
+                               return WebConfigurationManager.GetWebApplicationSection (section) as TSection;
+                       else
+                               return WebConfigurationManager.GetSection (section, vp) as TSection;
+               }
+               
+               internal VirtualPath VirtualPath {
+                       get;
+                       set;
+               }
+
                internal CompilationSection CompilationConfig {
-                       get {
-                               return WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
-                       }
+                       get { return GetConfigSection <CompilationSection> ("system.web/compilation"); }
                }
 
 #else
index 7a49596ab7df20a2c5b649a20f2ff372a07760b2..df0512cc780f661bc33fd5a45490a271fd6ced72 100644 (file)
@@ -1,3 +1,21 @@
+2009-04-21  Marek Habersack  <mhabersack@novell.com>
+
+       * SimpleWebHandlerParser.cs: retrieve CompilationSection from the
+       appropriate web.config file.
+
+       * BaseParser.cs: moved the internal property VirtualPath from
+       TemplateParser to here and added an internal method
+       GetConfigSection to retrieve sections from the correct web.config
+       file on 2.0 applications. Fixes bug #494245
+
+       * PageParser.cs: use the new GetConfigSection method to retrieve
+       ClientTargetSection.
+
+       * TemplateParser.cs: moved the VirtualPath property to
+       BaseParser.
+       PagesConfig now uses the new GetConfigSection method. Fixes bug
+       #494245
+
 2009-04-15  Marek Habersack  <mhabersack@novell.com>
 
        * TemplateParser.cs: use generic lists for import, namespace and
index 3140f223dbefc504cdab282eec140b571979582f..23467df38102af9f71ef526697983231eee2c50f 100644 (file)
@@ -316,7 +316,7 @@ namespace System.Web.UI
                        if (clientTarget != null) {
                                clientTarget = clientTarget.Trim ();
 #if NET_2_0
-                               ClientTargetSection sec = (ClientTargetSection)WebConfigurationManager.GetWebApplicationSection ("system.web/clientTarget");
+                               ClientTargetSection sec = GetConfigSection <ClientTargetSection> ("system.web/clientTarget");
                                ClientTarget ct = null;
                                
                                if ((ct = sec.ClientTargets [clientTarget]) == null)
@@ -387,11 +387,11 @@ namespace System.Web.UI
                
 #if NET_2_0
                internal override void AddDirective (string directive, Hashtable atts)
-               {                       
+               {
                        bool isMasterType = String.Compare ("MasterType", directive, StringComparison.OrdinalIgnoreCase) == 0;
                        bool isPreviousPageType = isMasterType ? false : String.Compare ("PreviousPageType", directive,
                                                                                         StringComparison.OrdinalIgnoreCase) == 0;
-                       
+
                        string typeName = null;
                        string virtualPath = null;
                        Type type = null;
index bb57e4db3735ed45fcc19eb438a6b29b7ed63a55..7d8e4ff41abac8a2baadf69719ba980921676f3c 100644 (file)
@@ -575,7 +575,11 @@ namespace System.Web.UI
 #if NET_2_0
                CompilationSection CompilationConfig {
                        get {
-                               return (CompilationSection)WebConfigurationManager.GetWebApplicationSection ("system.web/compilation");
+                               string vp = VirtualPath;
+                               if (String.IsNullOrEmpty (vp))
+                                       return WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
+                               else
+                                       return WebConfigurationManager.GetSection ("system.web/compilation", vp) as CompilationSection;
                        }
                }
 
index ade1364cc5214175d4520fd5c33c3e5610288684..ab9b3a50fbc8a7344c7db901a8897bd1d778460f 100644 (file)
@@ -206,7 +206,7 @@ namespace System.Web.UI {
                        if (BuildManager.HaveResources)
                                imports.Add ("System.Resources");
                        
-                       PagesSection pages = WebConfigurationManager.GetWebApplicationSection ("system.web/pages") as PagesSection;
+                       PagesSection pages = PagesConfig;
                        if (pages == null)
                                return;
 
@@ -1006,13 +1006,13 @@ namespace System.Web.UI {
                        get {
                                if (pageParserFilter != null)
                                        return pageParserFilter;
-                               
+
                                if (String.IsNullOrEmpty (pageParserFilterTypeName))
                                        return null;
 
                                pageParserFilter = Activator.CreateInstance (PageParserFilterType) as PageParserFilter;
                                pageParserFilter.Initialize (VirtualPath, this);
-                               
+
                                return pageParserFilter;
                        }
                }
@@ -1038,14 +1038,7 @@ namespace System.Web.UI {
                internal ILocation DirectiveLocation {
                        get { return directiveLocation; }
                }
-
-#if NET_2_0
-               internal VirtualPath VirtualPath {
-                       get;
-                       set;
-               }
-#endif
-
+               
                internal string ParserDir {
                        get {
                                if (includeDirs == null || includeDirs.Count == 0)
@@ -1347,9 +1340,7 @@ namespace System.Web.UI {
                }
                
                internal PagesSection PagesConfig {
-                       get {
-                               return WebConfigurationManager.GetWebApplicationSection ("system.web/pages") as PagesSection;
-                       }
+                       get { return GetConfigSection <PagesSection> ("system.web/pages") as PagesSection; }
                }
 
                internal AspGenerator AspGenerator {