[英]ASP.NET : How do I fetch data from a webserver every few minutes
I need to fetch CSV file from a webserver every few minutes. 我需要每隔几分钟从网络服务器获取CSV文件。
Here's what I am planning to do: I will create a webservice "GetCSV.asmx" which will get CSV file from that webserver. 我打算这样做:创建一个Web服务“ GetCSV.asmx”,该服务将从该Web服务器获取CSV文件。
I will create another webservice "RegularCall.asmx" which will call "GetCSV.asmx" every few minutes. 我将创建另一个Web服务“ RegularCall.asmx”,每隔几分钟将调用“ GetCSV.asmx”。
Is my approach correct? 我的方法正确吗? Is there a better way of doing this?
有更好的方法吗?
I am using ASP.NET web application and JSON webservice for this. 我为此使用ASP.NET Web应用程序和JSON Web服务。
NOTE: There will be NO user intervention and the solution I am looking for is similar to scheduling a task on the server...Can you please suggest a solution ? 注意:不会有用户干预,我正在寻找的解决方案类似于在服务器上安排任务...您能建议一个解决方案吗?
If you can do it from a client side call, use jQuery $.ajax and javascript setTimer to pull on interval. 如果您可以通过客户端调用来执行此操作,请使用jQuery $ .ajax和javascript setTimer设置间隔。 Set the ajax call to load the web service.
设置ajax调用以加载Web服务。
You should know that you don't need to create different asmx files. 您应该知道不需要创建其他asmx文件。 You can create one and access individual methods within it.
您可以创建一个并访问其中的单个方法。
Chad is right and this is a way you can call the ASMX WebService from JQuery . Chad是正确的,这是您可以从JQuery调用ASMX WebService的一种方式。 You just need to use,
您只需要使用,
<script language="JavaScript">
setInterval( "CallWebServiceFromJquery()", 300000 );
</script>
instead of
OnClientClick="CallWebServiceFromJquery()"
Note : 300000 miliseconds = 5 minutes 注意 :300000毫秒= 5分钟
I hope it would be helpful to you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.