Where is my ".aspx" file located

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

Hi there,

In a submit button event, I need to open a (server-side) file relative to
the folder containing the ".aspx" file. What's the correct way to locate the
".aspx" folder itself inside my handler? Thanks in advance.
 
MapPath(Request.FilePath) will return the physical file name for the current
page on the server. From that you can use methods of the System.IO.FileInfo
class to get to the name parts. I think there is a DirectoryName property
that should give you the folder path.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
MapPath(Request.FilePath) will return the physical file name for the
current page on the server. From that you can use methods of the
System.IO.FileInfo class to get to the name parts. I think there is a
DirectoryName property that should give you the folder path.

Thanks very much. That seems to do it. Once I have the physical path, can I
then work with it normally, i.e., there's nothing special I need to be aware
of in the IIS/ASP.NET environment (that is, I can work with the path as if I
were now running as the ISUR in a standalone, non-web app). Thanks again.
 
MapPath(Request.FilePath) will return the physical file name for the
Thanks very much. That seems to do it. Once I have the physical path, can
I then work with it normally, i.e., there's nothing special I need to be
aware of in the IIS/ASP.NET environment (that is, I can work with the path
as if I were now running as the ISUR in a standalone, non-web app). Thanks
again.

s/IUSR/ISUR
 
Creating or changing files will trigger your app to recompile, kicking
everyone off and resulting in a delay.
 
Creating or changing files will trigger your app to recompile, kicking
everyone off and resulting in a delay.

I'm reading a number of internal support files only (not ".aspx", ".html",
etc) but I'm not sure I follow you anyway. You mean if I change the ".aspx"
files themselves (which I have no intention of doing) then ASP.NET will
recompile the affected pages? Note that I'm new to ASP.NET but my conceptual
understanding of the ASP.NET lifecyle isn't too bad at this stage (having
read the MSDN docs at length). I'm no expert yet however so could you
briefly elaborate. Thanks.
 
if you create/write files, they should be in app_data folder, else you will
trigger an application recycle.

depending on the setup, impersonation settings, app pool identity, etc,
controls which user the asp.net thread is running as. if no impersonation,
then should
be the asp.net account or pool account if iis 6.0+

-- bruce (sqlwork.com)
 
if you create/write files, they should be in app_data folder, else you
will
trigger an application recycle.

depending on the setup, impersonation settings, app pool identity, etc,
controls which user the asp.net thread is running as. if no impersonation,
then should
be the asp.net account or pool account if iis 6.0+

Thanks for the info. I'll be looking into this ASAP. Note that there will be
no impersonation (security context is always IUSR if I understand things
correctly - I'm new to ASP.NET) and IIS is 6.0+. The files I'm referring to
are read-only however and never change (until the next release of my app).
Do these still go in "App_Data" or can I place then anywhere without
triggering the "recyle" you're referring to (which I'll be investigating).
Thanks for your assistance.
 
You're fine reading files, but if you change any or create new ones then IIS
will unload your app then re-load it. It allows IIS to re-read new settings
in the web.config file etc. Browse to your app, change the web.config file
and save it, re-load your app and you'll see a delay cos IIS is unloading
and reloading it.
 
You're fine reading files, but if you change any or create new ones then
IIS will unload your app then re-load it. It allows IIS to re-read new
settings in the web.config file etc. Browse to your app, change the
web.config file and save it, re-load your app and you'll see a delay cos
IIS is unloading and reloading it.

Ok, I'll need to research this further. Thanks for the info (appreciated).
 
Back
Top