I have a library code, which should be aware whether it is executed in the context of a web server or standalone application server.
The obvious that comes to mind i
Trying to solve another problem, I found a good solution for this one.
There is a private method System.Configuration.SettingsPropertyValue.IsHostedInAspnet, which does exactly what I need. Being a private method, I do not want to call it (though I could using reflection), but its implementation is trivial:
private bool IsHostedInAspnet()
{
return (AppDomain.CurrentDomain.GetData(".appDomain") != null);
}
(according to Reflector)
Looks like there is a special key in the app domain data - ".appDomain", which is set when running in ASP.NET web server.
I will stick to that.