By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,375 Members | 3,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,375 IT Pros & Developers. It's quick & easy.

Server.MapPath fails in Session_End event

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
See
http://msdn.microsoft.com/library/de...sevntonend.asp

"You cannot call the Server.MapPath
method in the Session_OnEnd script. "


Juan T. Llibre
ASP.NET MVP
===========
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #2

P: n/a
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.

"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #3

P: n/a
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
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
See
http://msdn.microsoft.com/library/de...sevntonend.asp

"You cannot call the Server.MapPath
method in the Session_OnEnd script. "


Juan T. Llibre
ASP.NET MVP
===========
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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


Nov 19 '05 #4

P: n/a
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
===========
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:uB**************@TK2MSFTNGP15.phx.gbl... 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
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
See
http://msdn.microsoft.com/library/de...sevntonend.asp

"You cannot call the Server.MapPath
method in the Session_OnEnd script. "

Juan T. Llibre
ASP.NET MVP
===========
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.