Reputation: 75
I have made a web application that sends email automatically when page loads. But how can I load my Default.aspx page automatically once a day on go daddy server where my website is hosted?
Upvotes: 0
Views: 256
Reputation: 93561
The overall problem is "How do I send an email every 24 hours". This really has nothing to do with web pages, except that is your current trigger mechanism. Better off changing your question to cover the overall aim, however...
You are better off having a separate task. One way is to use cache expiry as described here: https://blog.stackexchange.com/2008/07/easy-background-tasks-in-aspnet/
At startup, add an item to the HttpRuntime.Cache with a fixed expiration.
When cache item expires, do your work, such as WebRequest or what have you.
Re-add the item to the cache with a fixed expiration.
private static CacheItemRemovedCallback OnCacheRemove = null;
protected void Application_Start(object sender, EventArgs e)
{
AddTask("DoStuff", 60 * 60 * 24);
}
private void AddTask(string name, int seconds)
{
OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
HttpRuntime.Cache.Insert(name, seconds, null,
DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, OnCacheRemove);
}
public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
{
// do stuff here if it matches our taskname, like WebRequest
// re-add our task so it recurs
AddTask(k, Convert.ToInt32(v));
}
Upvotes: 1
Reputation: 562
Provided you have your page opened, you can add html metatag <meta http-equiv="refresh" content="86400"/>
to the head, which will reload it once a day.
Upvotes: 0
Reputation: 1541
There are a few options
If you have use of another machine that is always on, you can have a simple scheduled task or cron (depending on if it is windows or linux) to ping the url
If you have a free tier AWS or Azure account you can set yup schedules tasks, or one of the baove on those
Use a free monitoring service like pingdom this will ping every x minutes up to an hour i think, but there are others out there like pingability.com that can do this as well.
Upvotes: 0