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 is to check the name of the application configuration file and if it is web.config - then this is a web server, otherwise - standalone application server.
Another way is to look for something like "Temporary ASP.NET files" in the path of the shadow folder.
But I dislike both of these, since they seem too hacky and fragile. Is there a robust way to do what I want?
Thanks.
P.S.
One may define a dedicated app config setting - IsWebServer, but I dislike it even more.
EDIT:
While looking for a solution to another problem, I think I solved this one - the details are here
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…