Server.MapPath fails in Session_End event

A

Andy Fish

Hello,

I've found that if I try to do a Server.MapPath() in the Session_End event,
it fails with an exception.

is this right? any simple way to work round it?

is there any documentation that says what you can actually do in these
global.asax routines? - I've found out that Context is set to null but it
doesn't say that in any documentation I've seen

Andy
 
A

Arthur Dent

One way you could work around this is in Application_Start, get the
Server.MapPath result and stick it in an Application variable, then you can
refer to the app var during session on end. Make sure NOT to use a Session
variable, as these are all already gone by the time you get to Session_End.

HTH.
 
A

Andy Fish

Thanks Juan. This documentation is actually for asp rather than asp.net but
it seems the same rule applies. Typical how I managed to want the one call
that isn't available :-(

I guess maybe it needs to have a user context to map a path - I don't really
see why though
 
J

Juan T. Llibre

Hi, Andy.

re:
Thanks Juan.

You're very much welcome.

re:
This documentation is actually for asp rather than asp.net but it seems the
same rule applies.

Yes. The intrinsic objects behave the
same way in ASP as in ASP.NET.

There's some additional events in ASP.NET, and some nuances
regarding the way some of them behave but, basically, the way
the intrinsic objects are handled is the same.



Juan T. Llibre
ASP.NET MVP
===========
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top