【发布时间】:2016-07-01 05:45:34
【问题描述】:
我有一个具有 aspx 默认页面、一些 jquery 脚本和 .svc WCF 服务文件的 Visual Studio 项目。如果我用浏览器连接(非调试)它工作正常,但是当我在 VS 中调试并点击一个调用 Web 方法来显示服务器时间的按钮时,它第一次和第二次工作正常,但然后再次显示第一次和两次循环。如果我在 web 方法上设置断点,它不会在前几次之后中断。
这是否与他们在同一个项目中的事实有关?
对不起,这里是 JQuery 函数:
function controlOutput(outputNumber, state) {
var webMethod = "ControlOutput?DeviceIPAddress=" + adamsIPAddress + "&OutputNumber=" + outputNumber + "&State=" + state + "&vSessionID=" + sessionID;
var fullCommandURL = webServiceUrl + webMethod;
jQuery.support.cors = true;
$.ajax({
type: "GET", //GET or POST or PUT or DELETE verb
url: fullCommandURL, // Location of the service
contentType: 'application/json; charset=utf-8', // content type sent to server
dataType: "json", //Expected data format from server
success: function (result) {//On Successfull service call
connectionInfo = result;
$(h2Test).text(result);
//alert(result);
},
error: function (result) {// When Service call fails
alert(result.statusText);
}
});
}
以及 WCF 服务代码:
public string ControlOutput(string DeviceIPAddress, int OuputNumber, int State, Guid SessionID)
{
try
{
string ret = DateTime.Now.ToString("HH:mm:ss.fff");
AdamSocket adamSocket = new AdamSocket();
adamSocket.SetTimeout(1000, 1000, 1000);
bool con = adamSocket.Connect(DeviceIPAddress, ProtocolType.Tcp, 502);
bool res = adamSocket.Modbus().ForceSingleCoil(17, State);
adamSocket.Disconnect();
return ret;
}
catch (Exception ex)
{
LogEvent(null, "Application Exception", ex.Message, SessionID);
return "Failed";
}
}
【问题讨论】:
-
请发布您的代码,以便我们为您提供帮助。
-
有人可以帮忙吗?我原以为很多人都有这个问题,因为它在我的系统上非常可重现......