From a managed class library, I\'d like to find out whether the currently executing application is an ASP.NET web application (web forms or MVC) or not.
I have seen diff
I have to question your goal here: Why should the library be aware of what kind of application it is running from?
To me, it sounds like you need to split the relevant part of your library in two parts - one for use with web apps, and one for use with winforms apps. (And possibly a third part, with everything that can be used by both types of apps...)