Get IIS Path?

E

Eagle

How do I programmatically get the path of my application and IIS? For
instance, my application is in directory Working, but the progrm could be
running from different servers, so when I attempt to write to a file,
using HTTPContext.Current.Request.ApplicationPath, it tries to write to
c:\working, not c:\inetpub\wwwroot\... or whatever is the path on that
server.

Thanks for your help.
 
M

Mark Rae

How do I programmatically get the path of my application and IIS? For
instance, my application is in directory Working, but the progrm could be
running from different servers, so when I attempt to write to a file,
using HTTPContext.Current.Request.ApplicationPath, it tries to write to
c:\working, not c:\inetpub\wwwroot\... or whatever is the path on that
server.

Have a look at:

HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"]

and

HttpContext.Current.Request.ServerVariables["PATH_TRANSLATED"]
 
M

Mythran

Mark Rae said:
How do I programmatically get the path of my application and IIS? For
instance, my application is in directory Working, but the progrm could be
running from different servers, so when I attempt to write to a file,
using HTTPContext.Current.Request.ApplicationPath, it tries to write to
c:\working, not c:\inetpub\wwwroot\... or whatever is the path on that
server.

Have a look at:

HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"]

and

HttpContext.Current.Request.ServerVariables["PATH_TRANSLATED"]

-or-

VB.Net:

If aren't inside a Control (or derivation of Control) class:

HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath)

If you are inside a Control (or derivation of Control):
Server.MapPath(Request.ApplicationPath)

:) HTH

Mythran
 

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

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,208
Latest member
RandallLay

Latest Threads

Top