473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Server.MapPath fails in Session_End event

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
4 1669
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: raj | last post by:
Hi, I am facing a problem of automatic session timeout problem and automatic session_end event fired. Case1: As I have analyzed I get to know that the default session timeout is 20 in...
2
by: Chris Sibel | last post by:
Hey guys I have a user tracking setup to track users. What it does is once a user hits my site it sends me an email telling me some info and once a user clicks the logout button it sends a second...
3
by: MattB | last post by:
If I use server.mappath to get to the root dir of my application from within codebehind, it works fine. I also want to use this from a vb class I have in my application, and I think I have an issue...
5
by: Ron Vecchi | last post by:
1.) If I want to use an object that was stored in the Application state will it be avilable in the Session_End event. (even on the last session to end)?? 2.) Can I use the current sessions state in...
2
by: Anonymous | last post by:
Hello All, I recognized that Server.MapPath doesnt work in Session_End. Is there any other way to get the path? I dont think so, but I am hoping for other ways.
8
by: Roger | last post by:
When I call the session.abandon() method, it calls the session_end event. When a user closes the browser or clicks the log off button, I can dispose of objects and abandon the session cleaning....
3
by: Ricardo Vazquez | last post by:
Hi! I have a new problem with this SCENARIO I already described in a previous post: - PBX (a private telephone exchange or switch) - A Telephony Server Application running on computer "A" (it...
7
by: teo | last post by:
I need to use the 'Server.MapPath' function in the 'Session_End' event of the Global.asax file (to reach a folder and the clean some temporary files up), but it doesn't work: Sub...
5
by: greg | last post by:
Written in Asp.Net 2.0 The session_start fires on Development server running withing Visual Studio 2005 and also if access web site via localhost on development machine. But if copy to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.