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

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,823
Latest member
Nadia88

Latest Threads

Top