简体   繁体   English

在 Plesk 计划任务上运行 ASP.NET 代码

[英]Running ASP.NET code behind on Plesk Scheduled Task

Just want to ask if by any chance I can schedule an asp net code-behind to run every day at 00:00?只是想问一下我是否可以安排一个asp网络代码隐藏在每天00:00运行? What I am doing now is go to Plesk > Scheduled Task > Fetch URL and write the URL on it, hoping the Page Load event of the scheduled page to run.我现在正在做的是 go 到 Plesk > 计划任务 > 获取 URL 并编写 URL 并在其上运行计划页面的加载事件。 However it seems not to be the case.然而,情况似乎并非如此。

I am hosting a website on Hostgator in a sharing environment so Windows Scheduler is not feasible for me, Quartz is as well not feasible as I am an entire beginner for asp.net and still do not know how to exactly use it after googling an hour.我在共享环境中的 Hostgator 上托管了一个网站,因此 Windows 调度程序对我来说不可行,Quartz 也不可行,因为我是 asp.net 的初学者并且在谷歌搜索一个小时后仍然不知道如何准确使用它。 Do not even know how to write php so if this is your suggested solution please do make it clear甚至不知道如何写 php 所以如果这是您建议的解决方案,请务必说清楚

Any method please do suggest it任何方法请建议它

If anyone can help that would be highly appreciated.如果有人可以提供帮助,将不胜感激。 Thanks a lot in advance:)提前非常感谢:)

Another question另一个问题

cmd3.Parameters.AddWithValue("@sid", sid);
MySqlDataReader sdr2 = cmd3.ExecuteReader();
while (sdr2.Read())
{
    string clid = sdr2.GetString(0);
    string couid = sdr2.GetString(0).Split('-')[0] + "-" +b sdr2.GetString(0).Split('-')[1];
    string day = sdr2.GetString(1).ToLower();
    string start = sdr2.GetString(2) + ":00";
    string end = sdr2.GetString(3) + ":00";
    string teacher = sdr2.GetString(4);
    sqlconn.Close();
    sqlconn.Open();
    MySqlCommand cmd4 = new MySqlCommand("select " + gra + " from classes where courseid=@cid and " + gra + " is null", sqlconn);
    cmd4.Parameters.AddWithValue("@cid", couid);
    MySqlDataReader sdr3 = cmd4.ExecuteReader();
    if (sdr3.Read())
    {
        sqlconn.Close();
        sqlconn.Open();
        MySqlCommand cmd5 = new MySqlCommand("delete from enroll where classid = @clid and studentid=@sid;update " + day + " set currentstudent=currentstudent-1 where classid=@clid and start=@start and end=@end and teacher=@teacher", sqlconn);
        cmd5.Parameters.AddWithValue("@clid", clid);
        cmd5.Parameters.AddWithValue("@sid", sid);
        cmd5.Parameters.AddWithValue("@start", start);
        cmd5.Parameters.AddWithValue("@end", end);
        cmd5.Parameters.AddWithValue("@teacher", teacher);
        cmd5.ExecuteNonQuery();
    }
}

This gives an error of connection MySql.Data.MySqlClient.MySqlException: 'Invalid attempt to Read when reader is closed.'这给出了连接MySql.Data.MySqlClient.MySqlException: 'Invalid attempt to Read when reader is closed.' . . I think it is because I closed it's original connection of reading sdr2 when opening a new connection for sdr3 and for cmd5.我认为这是因为我在为 sdr3 和 cmd5 打开新连接时关闭了读取 sdr2 的原始连接。 Any way to solve this?有什么办法可以解决这个问题?

What you can do is:你可以做的是:

  1. Code your tasks in server side code (code behind) in your Web Application, and then schedule a (windows) task on a client PC to send an HTTP request to the URL of your web App (or web API) to trigger the url address for the code behind that does these tasks. Code your tasks in server side code (code behind) in your Web Application, and then schedule a (windows) task on a client PC to send an HTTP request to the URL of your web App (or web API) to trigger the url address对于执行这些任务的代码。

Scheduled Task : you can schedule a (Power) Shell Script that will start a browser or ( Postman ) with required URL that triggers your coded server tasks. Scheduled Task :您可以计划一个(电源)Shell 脚本,该脚本将启动浏览器或( Postman )触发您的编码服务器任务。 You just need to make sure that the system that has the scheduled task is on at the time of scheduled request and is configured with the right permissions.您只需要确保具有计划任务的系统在计划请求时处于打开状态并配置了正确的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM