How to detect IIS version using C#?

后端 未结 11 1724
栀梦
栀梦 2020-11-30 02:17

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

相关标签:
11条回答
  • 2020-11-30 03:03

    This is how i do it.

    FileVersionInfo verinfo = FileVersionInfo.GetVersionInfo(System.Environment.SystemDirectory + @"\inetsrv\inetinfo.exe");
    
    //Tip... look at verinfo.MajorVersion.
    
    0 讨论(0)
  • 2020-11-30 03:05

    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.

    0 讨论(0)
  • 2020-11-30 03:10

    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/

    0 讨论(0)
  • 2020-11-30 03:12

    In .NET 4.5

    HttpRuntime.IISVersion
    
    0 讨论(0)
  • 2020-11-30 03:14

    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

    0 讨论(0)
提交回复
热议问题