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
See the answer I provided here...
Basically, you can use HostingEnvironment.IsHosted.