When you will use the following code in Page_Load function of
String sRootPath = Environment.GetEnvironmentVariable(“RoleRoot”);
You will see different results depend on Full IIS Web Role
and HWC as below:
Full IIS Web Role – sRootPath
HWC Web Role – sRootPath = E:
This is because:
In Full IIS
configuration, the Web Role is running in WaIISHost.exe process however to Web
Site is running in w3wp.exe.
In HWC web role,
both the role and web site is running in WaWebHost.exe process.
With Full IIS the
web site process is not only a different appdomain but a different process
launched by a different service.
Because of it the
situation becomes complex to pass the role environment variables to web site.
You can write code
to pass this data via the registry or file system.
You can read service
configuration settings using the RoleEnvironment.GetConfigurationSettings.