Session and Requests

A

Andreas Zita

Hi!

I'm trying to make an xml-log of application, session and requests of my asp
..net app.

I was trying this layout:

<Application start="..." end="...">
<Session start="" end="">
<Request>
<UserDomain />
<... />
</Request>
<Request />
<... />
</Session>
</Application>

But apparently the session-object is started _after_ the first request. What
am I missing? Any recommendations here?

Thanks!

/Andreas Zita
 
L

Lucas Tam

But apparently the session-object is started _after_ the first
request. What am I missing? Any recommendations here?

Try writing this in the Session Start event handler in the Global.ASAX
file.
 
A

Andreas Zita

Lucas said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top