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.

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

You can download the HostingEnvironment project here



Comments

No comments yet.

Add Yours

  • Author Avatar

    YOU


Comment Arrow




About Author

Robert

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.