Where is my ".aspx" file located

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.
 
E

Eliyahu Goldin

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
 
J

Jack

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.
 
J

Jack

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
 
A

Aidy

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

Jack

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.
 
B

bruce barker

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)
 
J

Jack

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.
 
A

Aidy

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.
 
J

Jack

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,968
Members
47,518
Latest member
TobiasAxf

Latest Threads

Top