网页与 Web 服务通信
我有一个 ASP.NET 应用程序连接到 .NET Web 服务,每当我登录时到达主页后,网络服务将数据返回给我。
但是,如果我登录的时间可能超过 1 或 2 小时,当我单击任何链接时,我会得到:
System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException:连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接的主机未能响应而建立的连接失败。
不想在这里使用,我需要的只是网页& Web 服务应该始终进行通信。
解决这个问题的方法是什么?谢谢。
从操作评论更新为答案:
bool IsActive=WS.IsActive(ID);
IsActive 是一种 Web 方法:
[SessionExtension]
[DeveloperToken]
[SoapHeader("Session")]
[SoapHeader("developerToken")]
[WebMethod]
public bool IsActive(int ID) {
....code....
}
Web 服务代码中没有任何位置会在 1 或 2 小时超时后得出结果
I have a asp.net application connecting to a .net web service, whenever i login & reach the main page, web services returns me back the data.
But if i login for may be more than 1 or 2hrs, when i click any of the links i get:
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I don't use sessions & don't wish here to use, all i need to web page & web services should be communicated all the time.
What is the fix for this? Thanks.
update from op comments to an answer:
bool IsActive=WS.IsActive(ID);
IsActive is a web method:
[SessionExtension]
[DeveloperToken]
[SoapHeader("Session")]
[SoapHeader("developerToken")]
[WebMethod]
public bool IsActive(int ID) {
....code....
}
There is no where in the web service code that after some 1 or 2 hrs timing out of the result
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您正在尝试在本地主机上提供服务方法并获取数据,并且您做得正确。如果您在 1 小时内关闭本地主机连接,您将无法访问数据。您可以将该服务部署在服务器上,然后使其全职工作。
如果 asmx 已经在服务器端,您可以尝试调试代码,在代码上设置断点,运行它并使用 SOAP UI 向本地主机 URL 发送请求。
I guess you are trying to serve the service methods on localhost and get the data and you do that correctly. If you close your localhost connection in that 1 hour, you cannot reach the data. You can deploy the service on a server then to make it full time work.
If the asmx is already on the server side, you can try to debug the code maybe, with a breakpoint on the code, running it and sending request to your localhost URL using SOAP UI.