Reputation: 25
Just want to ask if by any chance I can schedule an asp net code-behind to run every day at 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. 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. Do not even know how to write php so if this is your suggested solution please do make it clear
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.'
. I think it is because I closed it's original connection of reading sdr2 when opening a new connection for sdr3 and for cmd5. Any way to solve this?
Upvotes: 0
Views: 478
Reputation: 2631
What you can do is:
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.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. 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.
Upvotes: 0