How to detect IIS version using C#?

后端 未结 11 1874
栀梦
栀梦 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 02:58

    You can get this information from the SERVER_SOFTWARE variable. It will return the following:

    Microsoft-IIS/5.0 (Windows 2000)
    Microsoft-IIS/5.1 (Windows XP)
    Microsoft-IIS/6.0 (Windows 2003 Server)

    etc.

    If you're using ASP.NET, you can get this string via

    Request.ServerVariables["SERVER_SOFTWARE"];
    

    EDIT: It seems that you will have to query the registry to get this information. Take a look at this page to see how.

提交回复
热议问题