Get IIS Path?

  • Thread starter Thread starter Eagle
  • Start date Start date
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.
 
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"]
 
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
 
Back
Top