Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Where is my ".aspx" file located

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 27 Feb 2008 16:07 GMT
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.
Eliyahu Goldin - 27 Feb 2008 16:23 GMT
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.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> 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.
Jack - 27 Feb 2008 16:33 GMT
> 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.
Jack - 27 Feb 2008 16:35 GMT
>> MapPath(Request.FilePath) will return the physical file name for the
>> current page on the server. From that you can use methods of the
[quoted text clipped - 6 lines]
> as if I were now running as the ISUR in a standalone, non-web app). Thanks
> again.

s/IUSR/ISUR
Aidy - 27 Feb 2008 17:26 GMT
Creating or changing files will trigger your app to recompile, kicking
everyone off and resulting in a delay.

>> MapPath(Request.FilePath) will return the physical file name for the
>> current page on the server. From that you can use methods of the
[quoted text clipped - 6 lines]
> as if I were now running as the ISUR in a standalone, non-web app). Thanks
> again.
Jack - 27 Feb 2008 18:04 GMT
> 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.
Aidy - 28 Feb 2008 09:48 GMT
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.

>> Creating or changing files will trigger your app to recompile, kicking
>> everyone off and resulting in a delay.
[quoted text clipped - 6 lines]
> stage (having read the MSDN docs at length). I'm no expert yet however so
> could you briefly elaborate. Thanks.
Jack - 28 Feb 2008 13:39 GMT
> 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).
bruce barker - 27 Feb 2008 18:08 GMT
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)

> > MapPath(Request.FilePath) will return the physical file name for the
> > current page on the server. From that you can use methods of the
[quoted text clipped - 5 lines]
> 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.
Jack - 27 Feb 2008 18:29 GMT
> if you create/write files, they should be in app_data folder, else you
> will
[quoted text clipped - 4 lines]
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.