简体   繁体   English

ASP.NET:如何每隔几分钟从Web服务器获取数据

[英]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 $ .ajaxjavascript 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.

相关问题 我如何让后台工作人员在 asp.net 核心中每 5 分钟更新一次数据存储 - how do i make a background worker to update a datastore every 5 minutes in asp.net core 如何使用ASP.net MVC从数据库中获取数据? - How to fetch data from database using ASP.net MVC? 当我使用 c# 从 asp.net 中的 DataTable 获取数据时,如何显示修改后的 header? - How to show modified header when I fetch data from DataTable in asp.net with c#? 在 ASP.NET web 应用程序中,我在哪种方法中实现一个每 5 分钟调用一次 function 的计时器? 没有 main() 可以在 PageLoad 中吗? - In ASP.NET web application, in which method do I implement a timer that calls a function every 5 minutes? There's no main() could it be in PageLoad? 使用ASP.net捕获窗口屏幕几分钟 - Capture the Window Screen for few minutes using ASP.net 如何对特定于用户的RSS阅读器进行编程,以每15分钟在C#ASP.NET中检查新的XML数据 - How to program a user-specific RSS reader that checks for new XML data every 15 minutes in C# ASP.NET 如何将数据从asp.net MVC控制器发布到非MVC asp.net页面? - How do I POST data from an asp.net MVC controller to a non-MVC asp.net page? 如何从选定目录ASP.NET加载几个文件 - How to load few files from chosen directory ASP.NET 如何将数据传递到ASP.NET WebAPI - How do I pass data to an ASP.NET WebAPI 如何在asp.net中处理大量数据 - How do I process large amount of data in asp.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM