Debug.Assert and Trace.Assert and ASP.NET
-
I'm trying to get Debug/Trace Assert messages... but failed to do so. Here's a simple ASP.NET scripts with a textbox that responds to TextChanged event: <%@ Import Namespace="System" %> <%@ Import Namespace="System.Diagnostics" %> void OnTextChanged(object sender, EventArgs e) { int num_hit; object _num; _num = ViewState["num_hit"]; if(_num == null) { ViewState["num_hit"]=1; } else { num_hit= (int)_num; num_hit++; ViewState["num_hit"]=num_hit; Response.Write("Number of hit: " + num_hit + "<br>"); } //QUESTION 1: Nothing comes from this line here!? I have already configured web.config <compilation debug="true" /> Debug.Assert(false, "dummy message title", "dummy message retail!"); //OKAY, I can see the trace output at the bottom of the page under section "Trace Information" (I've configued <trace enabled="true" .../>) Trace.Write("trace"); //QUESTION 2: Compilation error: CS0117: 'System.Web.TraceContext' does not contain a definition for 'Assert'...? Trace.Assert(false, "dummy message title", "dummy message retail!"); return; } Function OnClientClick() End Function Test Codebehind
Thanks in advance!
-
I'm trying to get Debug/Trace Assert messages... but failed to do so. Here's a simple ASP.NET scripts with a textbox that responds to TextChanged event: <%@ Import Namespace="System" %> <%@ Import Namespace="System.Diagnostics" %> void OnTextChanged(object sender, EventArgs e) { int num_hit; object _num; _num = ViewState["num_hit"]; if(_num == null) { ViewState["num_hit"]=1; } else { num_hit= (int)_num; num_hit++; ViewState["num_hit"]=num_hit; Response.Write("Number of hit: " + num_hit + "<br>"); } //QUESTION 1: Nothing comes from this line here!? I have already configured web.config <compilation debug="true" /> Debug.Assert(false, "dummy message title", "dummy message retail!"); //OKAY, I can see the trace output at the bottom of the page under section "Trace Information" (I've configued <trace enabled="true" .../>) Trace.Write("trace"); //QUESTION 2: Compilation error: CS0117: 'System.Web.TraceContext' does not contain a definition for 'Assert'...? Trace.Assert(false, "dummy message title", "dummy message retail!"); return; } Function OnClientClick() End Function Test Codebehind
Thanks in advance!
The "Trace" you are picking up is probably the Page.Trace which is a TraceContext not a System.Diagnostics.Trace. The TraceContext does not have an Assert. Rocky <>< www.GotTheAnswerToSpam.com
-
The "Trace" you are picking up is probably the Page.Trace which is a TraceContext not a System.Diagnostics.Trace. The TraceContext does not have an Assert. Rocky <>< www.GotTheAnswerToSpam.com
-
Thanks, but is it possible to Assert in ASP.NET? I tried Debug.Assert. The application compiled with no error, but nothing showed in trace and no pop up occurred)...
CillyMe wrote: Thanks, but is it possible to Assert in ASP.NET? As far as asserting with a popup, were would it popup a message on a web server? In a Windows application you are assured there is usually a user sitting there in front of the computer. On a web server nobody is usually logged in to the server. I do not know of debugging with Assert popups in ASP.NET. You might need to make a trace listener to handle them. Rocky <>< www.GotTheAnswerToSpam.com