tags:

views:

65

answers:

1

If I have an "application" defined in IIS Manager, I can get the value of the server variable APPL_MD_PATH to retrieve the physical path associated to the application.

If I have a "virtual directory" configured, APPL_MD_PATH still gives me the physical path associated to the application, not the physical path associated to the virtual directory.

  • How can I retrieve the physical path to the virtual directory to which the current request is associated?

  • How can I determine whether the request is being served from an application versus a virtual directory?

+2  A: 

You can use HSE_REQ_MAP_URL_TO_PATH_EX to find the physical path of any URL.

If you want to tell whether you are in a vdir or not, simply start walking up the URL by stripping off one rightmost segment at a time. Call HSE_REQ_MAP_URL_TO_PATH_EX until you either a) hit the application root or b) hit a physical directory which has a different prefix than the previous one. If (b) then you are in a virtual directory.

You can also use the approach above to find the physical path of the current vdir.

Justin Grant