Browse Source

2004-07-02 Gonzalo Paniagua Javier <[email protected]>

	* System.Web/TraceContext.cs: added internal HaveTrace property whose
	value is true when the page has a Trace attribute.

	* System.Web.Handlers/TraceHandler.cs: check that trace is enabled or
	throw.

	* System.Web.UI/Page.cs: added additional checks for saving/displaying
	trace data.

	* System.Web.UI/PageParser.cs: removed checks for trace enabled in
	configuration files.

	Thanks to David Taylor for most of these patch and the tests.

svn path=/trunk/mcs/; revision=30638
Gonzalo Paniagua Javier 21 years ago
parent
commit
8432e31ff8

+ 4 - 0
mcs/class/System.Web/System.Web.Handlers/ChangeLog

@@ -1,3 +1,7 @@
+2004-07-02 Gonzalo Paniagua Javier <[email protected]>
+
+	* TraceHandler.cs: check that trace is enabled or throw.
+
 2004-06-03  Gonzalo Paniagua Javier <[email protected]>
 
 	* TraceHandler.cs: Added protected missing members and attributes.

+ 15 - 4
mcs/class/System.Web/System.Web.Handlers/TraceHandler.cs

@@ -39,16 +39,27 @@ using System.Web.UI.WebControls;
 
 namespace System.Web.Handlers
 {
+#if NET_2_0
+	[Serializable]
+#endif
+	class TraceNotAvailableException : HttpException
+	{
+		public TraceNotAvailableException () :
+			base ("Trace Error") {}
+
+		internal override string Description {
+			get { return "Trace.axd is not enabled in the configuration file for this application."; }
+		}
+	}
+
 	public class TraceHandler : IHttpHandler
 	{
 		void IHttpHandler.ProcessRequest (HttpContext context)
 		{
 			TraceManager manager = HttpRuntime.TraceManager;
 
-			if (manager.LocalOnly && !context.Request.IsLocal) {
-				// Need to figure out the error message that goes here
-				// but I only have cassini for testing
-				return;
+			if (!manager.Enabled || manager.LocalOnly && !context.Request.IsLocal) {
+				throw new TraceNotAvailableException ();
 			}
 				
 			HtmlTextWriter output = new HtmlTextWriter (context.Response.Output);

+ 7 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,10 @@
+2004-07-02 Gonzalo Paniagua Javier <[email protected]>
+
+	* Page.cs: added additional checks for saving/displaying trace data.
+
+	* PageParser.cs: removed checks for trace enabled in configuration
+	files.
+
 2004-06-29 Gonzalo Paniagua Javier <[email protected]>
 
 	* ControlCollection.cs: when clearing the control collection, tell the

+ 9 - 2
mcs/class/System.Web/System.Web.UI/Page.cs

@@ -769,11 +769,18 @@ public class Page : TemplateControl, IHttpHandler
 
 	private void RenderTrace (HtmlTextWriter output)
 	{
-		if (!Trace.IsEnabled)
+		TraceManager traceManager = HttpRuntime.TraceManager;
+
+		if (Trace.HaveTrace && !Trace.IsEnabled || !Trace.HaveTrace && !traceManager.Enabled)
 			return;
 		
 		Trace.SaveData ();
-		Trace.Render (output);
+
+		if (!Trace.HaveTrace && traceManager.Enabled && !traceManager.PageOutput) 
+			return;
+
+		if (!traceManager.LocalOnly || Context.Request.IsLocal)
+			Trace.Render (output);
 	}
 	
 	internal void RaisePostBackEvents ()

+ 0 - 14
mcs/class/System.Web/System.Web.UI/PageParser.cs

@@ -199,13 +199,6 @@ namespace System.Web.UI
 				}
 			}
 
-			TraceConfig traceConfig = (TraceConfig) Context.GetConfig ("system.web/trace");
-			if (traceConfig != null) {
-				trace = traceConfig.Enabled;
-				if (trace)
-					haveTrace = true;
-			}
-
 			string tracestr = GetString (atts, "Trace", null);
 			if (tracestr != null) {
 				haveTrace = true;
@@ -227,13 +220,6 @@ namespace System.Web.UI
 							"one of the following values: SortByTime, SortByCategory.");
 			}
 
-			if (traceConfig != null) {
-				if (traceConfig.LocalOnly && !Context.Request.IsLocal) {
-					haveTrace = false;
-					trace = false;
-				}
-			}
-			
 			errorPage = GetString (atts, "ErrorPage", null);
 			validateRequest = GetBool (atts, "ValidateRequest", PagesConfig.ValidateRequest);
 			clientTarget = GetString (atts, "ClientTarget", null);

+ 5 - 0
mcs/class/System.Web/System.Web/ChangeLog

@@ -1,3 +1,8 @@
+2004-07-02 Gonzalo Paniagua Javier <[email protected]>
+
+	* TraceContext.cs: added internal HaveTrace property whose
+	value is true when the page has a Trace attribute.
+
 2004-06-15 Gonzalo Paniagua Javier <[email protected]>
 
 	* TraceData.cs: fixed <br> output. Closes bug #60181.

+ 9 - 0
mcs/class/System.Web/System.Web/TraceContext.cs

@@ -42,11 +42,19 @@ namespace System.Web {
       private TraceMode _Mode;
       private TraceData data;
       private bool data_saved;
+      private bool _haveTrace = false;
            
       public TraceContext(HttpContext Context) {
 	 _Context = Context;
 	 _Enabled = false;
       }
+
+
+	internal bool HaveTrace {
+		get {
+			return _haveTrace;
+		}
+	}
 
       public bool IsEnabled {
 	 get {
@@ -56,6 +64,7 @@ namespace System.Web {
 	 set {
 		 if (value && data == null)
 			 data = new TraceData ();
+	     _haveTrace = true;
 	    _Enabled = value;
 	 }
       }