Using HostingEnvironment Class

Each managed website application has a single static instance of the HostingEnvironment class which provides access to application management and services functions.

In this example we will explore a few of the members that might come in handy.

This returns a unique identifier as a string e.g. 14004b97
This returns the physical location of app e.g. E:\Testing\HostingEnvironmentTestApp\
This returns the virtual location e.g. the root of the website would be /
This returns the name of the website in IIS e.g. Default Web Site

You can download the HostingEnvironment project here


No comments yet.

Add Yours

  • Author Avatar


Comment Arrow

About Author


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning hands down.