Установить переменную сеанса в Application_BeginRequest

Я использую ASP.NET MVC, и мне нужно установить переменную сеанса в Application_BeginRequest . Проблема в том, что на данный момент объект HttpContext.Current. Сеанс всегда нулевой .

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    if (HttpContext.Current.Session != null)
    {
        //this code is never executed, current session is always null
        HttpContext.Current.Session.Add("__MySessionVariable", new object());
    }
}
37
задан John Saunders 31 December 2014 в 03:59
поделиться

0 ответов

Другие вопросы по тегам:

Похожие вопросы: