Re: [Global.asax] function Server.MapPath not available ?
- From: "Juan T. Llibre" <nomailreplies@xxxxxxxxxxx>
- Date: Sun, 10 Dec 2006 22:25:06 -0400
From Stephen Walter's "ASP.NET Unleashed" :
Within an ASP.NET page, the Page object is the default object.
In many cases, if you do not specify an object when you call a method or access a property,
you are implicitly calling the method or accessing the property from the Page object.
For example, when you call the MapPath method (which maps virtual paths to physical paths),
you are actually calling the Page.MapPath method. Or, when you access the Cache property,
you are implicitly accessing the Page.Cache property.
The Global.asax file does not have the Page object as its default object.
This means that you cannot simply call a method such as MapPath and expect it to work.
Fortunately, in most cases, you can use a simple workaround.
Instead of calling the MapPath method, you can call the Context.MapPath method.
Or, instead of accessing the Page.Cache object, you can access the Context.Cache object.
If a familiar property or method does not work in the Global.asax file,
you should immediately try calling the method or property by using the Context object instead.
Try it.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"teo" <teo@xxxxxxxxx> wrote in message news:l3dpn296mne01j3qdfosl6rbfcspssaoal@xxxxxxxxxx
Mark,
I tried
the 'public' folder is here
www.mySite.it/public/myFolder
and
my .aspx page folder is here
www.mySite.it/PersonalApp/Default.aspx
also
the InProc is set on
unfortunately
'Server.MapPath' and 'Request.ApplicationPath'
from the Session_End
both return an empty string
- - -
Because Server.MapPath on the Session_Start does work ,
I tried to store the resulting string in a variable
to use it in the Session_End ,
but it seems that
the Global.asax file manages variable differently from usual
and it 'looses' its content
and nothing arrives in the Session_End event
- - -
I 'm stumped
(I'm performing my tasks
on the Session_ Start event,
but I don't like it because it consumes time)
.
- Follow-Ups:
- References:
- [Global.asax] function Server.MapPath not available ?
- From: teo
- Re: [Global.asax] function Server.MapPath not available ?
- From: Mark Fitzpatrick
- Re: [Global.asax] function Server.MapPath not available ?
- From: teo
- [Global.asax] function Server.MapPath not available ?
- Prev by Date: Re: How do you acces ASP.NET WAT on a Web server that doesnt have
- Next by Date: Re: typed dataset xsd
- Previous by thread: Re: [Global.asax] function Server.MapPath not available ?
- Next by thread: Re: [Global.asax] function Server.MapPath not available ?
- Index(es):
Relevant Pages
|