Webmethod asp.net中的断言方法

时间:2012-04-17 15:14:03

标签: asp.net pagemethods webmethod

我有一个使用页面方法调用的Web方法。虽然条件失败,但断言功能不起作用。

我想测试我的代码失败的条件,并在Assert menthod中调试它。

我应该如何调试该网络menthod。请建议。

JavaScript代码

function sendingRqstForDealerCard(Argument) {

PageMethods.DealerTurn(OnSuccess);
function OnSuccess(response) {

    Sys.Debug.assert(response!="", "respone is blanck in DealerTurn Function");
}

javascript assert正在运行,但我必须检查代码背后的代码。

代码背后

 [WebMethod]
 public static string DealerTurn()
 {    
 string previousRowHandTotal = BLHand.GetHandTotalField(hand, Convert.ToUInt16(dealerSpotID));

   System.Diagnostics.Debug.Assert(previousRowHandTotal != string.Empty,"previousRowHandTotal is empty in dealerTurn function."); 
}    

还有其他方法可以调试WebMethod吗?

1 个答案:

答案 0 :(得分:2)

您需要提供更全面的答案代码,但请记住,如果您使用的是Debug.Assert而未在调试模式下运行,则Assert甚至不会编译到代码中。这可能是你的断言没有触发的原因。

Here is a MSDN article on how to run in debug mode。通常,如果您从visual studio运行,那么这应该会提示您更改设置,但