Any reliable elegant way of detecting whether the current app is a win or web forms (or other) application?
We have a common config class which needs to open either app.config or web.config.
Currently, I’m catching ArgumentException when I try OpenExeConfiguration but it’s not very elegant and might mask other issues.
I usually check if there’s a HttpContext available (if it’s a Web Application since in a Web Service
HttpContenxt.Currentis null)To do this, you should add
System.Webto your references.