Hope this helps,
DirectoryEntry site = new DirectoryEntry(@"IIS://localhost/w3svc/1/Root"); PropertyValueCollection values = site.Properties["ScriptMaps"]; foreach (string val in values) { if (val.StartsWith(".aspx")) { string version = val.Substring(val.IndexOf("Framework") + 10, 9); MessageBox.Show(String.Format("ASP.Net Version is {0}", version)); } }
The map script property is an array of strings. If the application supports asp.net, one of these lines will display the aspx file extension for the asp.net handler, which will be the full path to the DLL. The path will look like
% Windir% / Microsoft.NET / Framework // aspnet_isapi.dll.
You can get the version from this line using simple parsing.
source share