C# 是否可以在aspx网页本身中跟踪/查看会话的值?
我正在调试一个包含几个类的项目网站;虽然大多数代码是用C#处理的,但基于HTML的页面中有几个if语句,它们使用会话来更新自身 例如,我按下一个按钮,基于HTML的页面调用一个Javascript函数,然后调用一个C#函数C# 是否可以在aspx网页本身中跟踪/查看会话的值?,c#,asp.net,visual-studio,C#,Asp.net,Visual Studio,我正在调试一个包含几个类的项目网站;虽然大多数代码是用C#处理的,但基于HTML的页面中有几个if语句,它们使用会话来更新自身 例如,我按下一个按钮,基于HTML的页面调用一个Javascript函数,然后调用一个C#函数 <input class='buttonbrowse' type="button" name="btnShiftDate" value="..." <%=(requestApplicationForm.Paycode==null ? " disabled=disa
<input class='buttonbrowse' type="button" name="btnShiftDate" value="..." <%=(requestApplicationForm.Paycode==null ? " disabled=disabled" : "")%> onclick="javascript:SelectExcessHrs_time();" id="Button1" />
回到HTML页面,会发生以下情况:
<%if(requestApplicationForm.Excessdatepunch!=null) {%>
等等,等等。基本上,HTML页面中嵌入了内嵌的C代码(人们会这么称呼它们吗?)。很多代码。他们会对工资代码表进行某种过滤
Excessdatepunch是一个数组,它包含将paycodeform传递回会话时的值。不幸的是,在HTML代码的某个地方,Excessdatepunch数组被清除,并重新提供了默认值——在一长串代码中运行是令人沮丧的,而且使事情进一步复杂化的是,这个错误并不经常发生
关于标题,我想问一下是否有办法监控这些在线C#代码。我知道在那里放置断点是不起作用的,而在会话上放置一个手表并不能准确地给出内部工作,例如Excessdatepunch数组中的值。您可以使用System.Diagnostics.Debugger.break()
中断ASPX中的代码执行。您还可以写入跟踪和调试侦听器。尝试调试以下代码示例:
<form id="form1" runat="server">
<div>
This is some HTML. The current time is:
<%
System.Diagnostics.Debugger.Break();
Session["CurrentTime"] = DateTime.Now;
%>
</div>
<%
System.Diagnostics.Trace.WriteLine(Session["CurrentTime"]);
System.Diagnostics.Debug.WriteLine(Session["CurrentTime"]);
System.Diagnostics.Debugger.Break();
Response.Write(Session["CurrentTime"]);
Response.Write("<br/>");
%>
You should see the current date above this line.
</form>
参考资料:
<form id="form1" runat="server">
<div>
This is some HTML. The current time is:
<%
System.Diagnostics.Debugger.Break();
Session["CurrentTime"] = DateTime.Now;
%>
</div>
<%
System.Diagnostics.Trace.WriteLine(Session["CurrentTime"]);
System.Diagnostics.Debug.WriteLine(Session["CurrentTime"]);
System.Diagnostics.Debugger.Break();
Response.Write(Session["CurrentTime"]);
Response.Write("<br/>");
%>
You should see the current date above this line.
</form>
<%@ Page Language="C#" Trace="true" ... %>