Reputation: 37398
What details can I get of the process hosting my ASP.NET code (i.e. Cassini, IIS etc)?
I know of System.Environment
but its not overly informative for web apps.
Is there anything else available?
Thanks
Upvotes: 2
Views: 806
Reputation: 7813
If you only are interested in what kind of environment that you are running in, you can check
AppDomain.Current.FriendlyName
or
System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName
We have a test like this in a project:
AppDomain appDomain = AppDomain.CurrentDomain;
if (appDomain.FriendlyName.ToUpper().StartsWith("/LM/W3SVC/") || // IIS
appDomain.FriendlyName.ToLower().EndsWith(".test.dll") || // Support for unit test as long as it ends with .test.dll.
(System.Diagnostics.Process.GetCurrentProcess().MainModule != null) && System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName.Equals("WebDev.WebServer.EXE", StringComparison.CurrentCultureIgnoreCase)) // Support for Cassini.
{
...
}
It is not pretty, but it works.
Upvotes: 4
Reputation: 2714
You can get some more info from HttpRuntime, but not everything.
http://msdn.microsoft.com/en-us/library/system.web.httpruntime_members.aspx
Upvotes: 1