Application Keep Alive在共享主机中,无法访问IIS管理器

Roh*_*ora 3 c# asp.net iis web-config

我正在使用GoDaddy的共享主机.我的网站通常需要时间来加载每次我打开它后一段时间.我开始知道Asp.net网站在一段时间后再次启动.

然后我才知道我们可以通过IIS管理器保持我们的网站.但我无法访问IIS管理器,因为我正在使用共享主机.我每次都可以保持我的申请吗?

我们在web.config中有任何设置来保持应用程序活着吗?

Roh*_*ora 6

Atlast我在另一个网站上得到了一个解决方案:这里是链接Keep alive IIS而不访问IIS管理器

如果链接被破坏.我会在这里解释一下:

将此代码添加到您的global.asax文件并在App_Start中调用它,它将通过运行简单的刷新作业自动保持您的网站.

private static void _SetupRefreshJob()
{
   //remove a previous job
   Action remove = HttpContext.Current.Cache["Refresh"] as Action;
   if (remove is Action)
   {
       HttpContext.Current.Cache.Remove("Refresh");
       remove.EndInvoke(null);
   }
   //get the worker
   Action work = () =>
   {
       while (true)
        {
          Thread.Sleep(60000);
          WebClient refresh = new WebClient();
          try
          {
           refresh.UploadString("http://www.websitename.com/", string.Empty);
          }
          catch (Exception ex)
          {
                    //snip...
          }
          finally
          {
            refresh.Dispose();
          }
      }
  };
  work.BeginInvoke(null, null);

  //add this job to the cache
  HttpContext.Current.Cache.Add(
  "Refresh",
  work,
  null,
  Cache.NoAbsoluteExpiration,
  Cache.NoSlidingExpiration,
  CacheItemPriority.Normal,
  (s, o, r) => { _SetupRefreshJob(); }
  );
}
Run Code Online (Sandbox Code Playgroud)