Lucas Tam wrote:
Try writing this in the Session Start event handler in the Global.ASAX
file.
This is how Im doing it now (simplified):
protected void Application_Start(Object sender, EventArgs e)
{
XmlElement currLogApp = log.CreateElement("Application");
log.DocumentElement.AppendChild(currLogApp);
Application["LogApp"] = currLogApp;
}
protected void Session_Start(Object sender, EventArgs e)
{
XmlElement currLogSess =
((XmlDocument)Application["Log"]).CreateElement("Session");
((XmlElement)Application["LogApp"]).AppendChild(currLogSess);
Application["LogSession"] = currLogSess;
}
protected void Application_BeginRequest(Object sender, EventArgs e)
{
XmlElement request =
((XmlDocument)Application["Log"]).CreateElement("Request");
((XmlElement)Application["LogSession"]).AppendChild(request); // Here is
the problem!
}
But Application["LogSession"]) is null when the request begins since the
session hasnt started yet.
How can I know which Session a certain Request is bound to? Or isnt a
Request bound to a Session at all? Is my approach wrong?
/Andreas Zita