0
當我在我的機器上進行調試時,httpModule現在在將它發佈到IIS後正常啓動,它不會運行,我做錯了什麼?我錯過了什麼嗎?發佈到IIS時,httpModule不會觸發
這裏是什麼樣子在web.config中
<httpModules>
<add type="MyApp.Web.Mvc.Modules.Scheduler" name="Scheduler" />
</httpModules>
然後,調度器看起來像這樣
public class Scheduler : IHttpModule
{
private static readonly object Job;
private static Timer timer;
static Scheduler()
{
Job = new object();
}
void IHttpModule.Init(HttpApplication application)
{
try
{
if (timer == null)
{
var timerCallback = new TimerCallback(ProcessJobs);
const int startTime = 10 * 1000;
const int timerInterval = 60 * 1000; // 1 minute
timer = new Timer(timerCallback, null, startTime, timerInterval);
}
}
catch (Exception ex)
{
//exception code here
}
}
public void Dispose()
{
}
protected void ProcessJobs(object state)
{
try
{
// This protects everything inside from other threads that might be invoking this
// which is good for long running processes on the background
lock (Job)
{
//My Stuff
}
}
catch (Exception ex)
{
//exception code here
}
}
}
工程處理和感謝的鏈接我會解決它,無論如何調度程序調用另一個web服務器上的web API不在同一個域。 – Raymund