我有以下工作調度運行每分鐘使用hangfire試圖保持我的網站活着,但它似乎仍然閒置?我剛剛檢查了遲髮型儀表盤,看起來像,因爲沒有人訪問該網站(注意這是一個Intranet應用程序)ASP.Net應用程序空閒超時和應用程序池回收
try
{
var url = "http://xyz.domain.com/myapp"
var request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 6000;
request.AllowAutoRedirect = false;
request.Method = "HEAD";
using (var response = request.GetResponse())
{
// TO DO
}
}
catch (Exception ex)
{
logger.Error(ex, "Error in KeepAlive job");
}
會使用Web客戶端更可靠的工作從來沒有在週末跑了過來presumembly或者是相同的如使用的HttpWebRequest -something象下面這樣:
WebClient webClient = new WebClient();
Stream stream = webClient.OpenRead("http://xyz.domain.com/myapp");