How to detect IIS version using C#?
Update: I meant from a winapp (actually the scenario is developing a custom installer that wants to check the version of the inst
This is how i do it.
FileVersionInfo verinfo = FileVersionInfo.GetVersionInfo(System.Environment.SystemDirectory + @"\inetsrv\inetinfo.exe");
//Tip... look at verinfo.MajorVersion.
I would just check the version of the OS: xp has IIS 5.1, Server 2003 has IIS 6 and vista/Server 2008 has IIS 7.
Here's how to check the version of the OS.
For installer with custom actions: In your custom action view, you can pass data to your customer installer class via the "CustomActionData" attribute in the properties for the custom action as follows: /iisv="[IISVERSION]"
Check:
http://johnbarshinger.wordpress.com/2006/10/27/how-to-modify-the-vs2005-installer-to-set-the-asp-net-version-and-create-application-pools/
In .NET 4.5
HttpRuntime.IISVersion
You can use below code
public static bool IisInstalled()
{
try
{
using (RegistryKey iisKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\InetStp"))
{
return (int)iisKey.GetValue("MajorVersion") >= 6;
}
}
catch
{
return false;
}
}
fore more information visit : http://www.java2s.com/Code/CSharp/Windows/IIShelperisIISInstalledIISstateIISversion.htm