无需单击aspx页面中的按钮即可自动运行程序 [英] Automatically run program without click the button in aspx page

查看:150
本文介绍了无需单击aspx页面中的按钮即可自动运行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a question for task scheduler.
I have a button in aspx page and this button does the below when aspx page is Page_Load
-	Connect web service
-	Get json data from web service
-	Update my table on Sql Server

Wondering what the next step is in order to run automatically everyday 9:00am
Do I have to create exe file? Or .bat file or .dll ?
Or task scheduler can run aspx page?

Any help would be greatly appreciated. Thank you in advance for your help.





我尝试了什么:



用Google搜索最佳解决方案,但仍然没有线索。



What I have tried:

Googled the best solution but still no clue.

推荐答案

由于Web的工作方式,ASP.Net是在调度任务时使用的错误平台。在有人访问页面之前代码没有运行,然后服务器运行页面的代码,将html发送回客户端,然后断开连接并无限期地等待其他人请求页面。



您当然可以将代码放入exe中,然后安排它。但是,由于您已经在网页中拥有代码,因此您可以通过最快的方式安排此操作,即可创建一个批处理文件,在服务器上加载网页,然后安排该网页。



请参阅 windows - 如何我可以在默认浏览器中按计划打开URL吗? - 超级用户 [ ^ ]有关如何运行网页的示例。基本上你放开始或浏览器,然后是网址。非常简单。
ASP.Net is the wrong platform to use when scheduling tasks because of the way the web works. The code is not running until someone visits the page, then the server runs the code for the page, sends the html back to the client and then disconnects and waits indefinitely for someone else to request a page.

You could certainly take the code and put it into an exe and then schedule that. However, since you already have the code in a webpage your fastest way to schedule this is to probably create a batch file that loads the webpage on the server and then schedule that.

See windows - How can I open a URL on a schedule in the default browser? - Super User[^] for examples on how to run a webpage. Essentially you put start or explorer and then the url. Pretty simple.


我,我在我的托管服务上设置了一个预定的事件,它以特定的间隔为我运行特定的应用程序。

对于Arvixe,有这里的描述:如何使用DotNetPanel中的Schedule Task来执行URL | Arvixe博客 [ ^ ]但您的托管服务可能会有所不同。
Me, I set a scheduled event on my hosting service which runs a specific application for me at a specific interval.
For Arvixe, there is a description here: How to Use Schedule Task in DotNetPanel to Execute a URL | Arvixe Blog[^] but it will probably be different for your hosting service.


您可以尝试查看在以下位置创建WinService的教程:

演练:在组件设计器中创建Windows服务应用程序 [ ^ ]



对于你的情况,我认为你必须将Button_Click EventHandler中的代码复制到WinService的EntryPoint,在文章中命名为MyNewService()。



希望它能提供帮助。
You may try to take a look at the tutorial for creating a WinService at:
Walkthrough: Creating a Windows Service Application in the Component Designer[^]

For you situation, I think you have to copy the code inside the Button_Click EventHandler into the EntryPoint of the WinService, which is named "MyNewService()" in the article.

Hope it'll help.


这篇关于无需单击aspx页面中的按钮即可自动运行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆