我使用httpruntime缓存每30分钟运行一段代码。该站点托管在共享环境中。直到上个星期,它都运行得很好。未更改任何代码,但它停止工作。
除了“应用程序启动”电子邮件,我还没有收到任何其他电子邮件。有没有关于如何找到问题的建议?
谢谢。
void Application_Start(object sender, EventArgs e)
{
RegisterCache();
SendEMail("Application Started");
}
private void RegisterCache()
{
try
{
HttpRuntime.Cache.Add("dummy", "dummy", null, DateTime.UtcNow.AddMinutes(30),
Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable,
new CacheItemRemovedCallback(OnCacheItemRemoved));
}
catch (Exception ex)
{
SendEMail(ex.Message);
}
}
public void OnCacheItemRemoved(string key, object value, CacheItemRemovedReason reason)
{
try
{
RegisterCache();
// ... get data from the interweb, email data...
}
catch (Exception ex)
{
SendEMail(ex.Message);
}
finally
{
SendEMail("Cache Item Removed");
}
}
void Application_End(object sender, EventArgs e)
{
SendEMail("Application Ended");
}发布于 2015-07-24 07:35:40
一个可能的原因是IIS应用程序池中的空闲超时设置。默认情况下设置为20分钟。这将导致您的网站“关闭”,并且您的缓存移除事件将不会触发。
https://stackoverflow.com/questions/31596410
复制相似问题