Я создал один таймер. После вызова таймера мне нужно перенаправить на другую страницу.Как получить доступ к HttpContext.Current в другом потоке
Пожалуйста, помогите мне.
Мой код:
System.Timers.Timer myTimerfortodolist;
void Application_Start(object sender, EventArgs e)
{
myTimerfortodolist = new System.Timers.Timer();
myTimerfortodolist.Interval = 60000;//86400000 milisecond is equal to 24;
myTimerfortodolist.AutoReset = true;
myTimerfortodolist.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_TODO);
myTimerfortodolist.Enabled = true;
}
//create for check send Interval from Reminder Config within 5 minute
public void myTimer_TODO(object source, System.Timers.ElapsedEventArgs e)
{
if (//Condition//)
{
Response.Redirect("~/Authorize.aspx");
}
}
Ответ не доступен в этом контексте.
Я Перенаправление от страницы к другой и таймер работает на каждые 1 мин, так что я смог Текущий HttpContext в методе делегата
TRY 'HttpContext.Current.Response'. Также не уверен, что в 'Application_Start' вы можете получить' Context'. Посмотрите на [эта ссылка] (http://stackoverflow.com/questions/2518057/request-is-not-available-in-this-context) –
HttpContext.Current, имеющий нулевое значение в потоке myTimer_TODO –
Невозможно прокомментировать , Вот ответ -> http://stackoverflow.com/a/9977501 –