chirag
chirag

Reputation: 75

How to automatically refresh url once in a day on hosting site

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

Answers (3)

iCollect.it Ltd
iCollect.it Ltd

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/

  1. At startup, add an item to the HttpRuntime.Cache with a fixed expiration.

  2. When cache item expires, do your work, such as WebRequest or what have you.

  3. Re-add the item to the cache with a fixed expiration.

Code (from that site):

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

myroman
myroman

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

Symeon Breen
Symeon Breen

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

Related Questions