Re: [Global.asax] function Server.MapPath not available ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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)




.



Relevant Pages

  • Re: [Global.asax] function Server.MapPath not available ?
    ... Instead of calling the MapPath method, you can call the Context.MapPath method. ... maybe I always adopted a wrong syntax, ... but I always saw the blu irregular underline ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Can not get past the welcome screen
    ... Calling an illegal alien an "undocumented worker" is like calling a ... will bring up a window, in that window on the left side you should see ... that will unzip the files to a folder. ... folder and select the iso file. ...
    (microsoft.public.windowsxp.general)
  • Re: quick question on folder browsing
    ... >> Browse Folder dialog, much easier than calling the thing directly. ... I gave the Google approach to encourage its' use for a resource to use after first perusing the ... miniFaqs. ...
    (alt.comp.lang.borland-delphi)
  • how to launch debug.exe before setup.exe using bootable cd for winxp setup
    ... manually create and format hard disk partition.Hard disk should be ... 2)added a folder as Tools into it, into this folder i have copied ... 4)configured Autorun.inf,i.e in the open parameter instead of calling ... already checked the boot order in BIOS which is correct. ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: $_REQUEST
    ... Calling the first URL everything works fine, calling the second I get an ... error saying 'VAR2' is not in the array $_REQUEST. ... want my function to return an empty string. ... > Kind Regards ...
    (alt.php)