ASP.NET: переменная сеанса доступа в global.asax
У меня есть приложение ASP.NET и в Global.asax & apos; Событие ошибки приложения, я вызываю метод для отслеживания / регистрации ошибки. Я хочу использовать содержимое переменной сеанса здесь. Я использовал приведенный ниже код
void Application_Error(object sender, EventArgs e)
{
//get reference to the source of the exception chain
Exception ex = Server.GetLastError().GetBaseException();
//log the details of the exception and page state to the
//Windows 2000 Event Log
GUI.MailClass objMail = new GUI.MailClass();
string strError = "MESSAGE: " + ex.Message + "<br><br><br>" + "SOURCE: " + ex.Source + "<br>FORM: " + Request.Form.ToString() + "<br>QUERYSTRING: " + Request.QueryString.ToString() + "<br>TARGETSITE: " + ex.TargetSite + "<br>STACKTRACE: " + ex.StackTrace;
if (System.Web.HttpContext.Current.Session["trCustomerEmail"] != null)
{
strError = "Customer Email : " + Session["trCustomerEmail"].ToString() +"<br />"+ strError;
}
//Call a method to send the error details as an Email
objMail.sendMail("[email protected]", "[email protected]", "Error in " + Request.Form.ToString(), strError, 2);
}
Я получаю сообщение об ошибке в строке кода, где я получаю доступ к переменной сеанса. Visual Studio сообщает, что
"Session is not available in this context"
Как от этого избавиться? Какие-нибудь мысли?
заранее спасибо