如何使用 C# 检测 IIS 版本? [英] How to detect IIS version using C#?
问题描述
如何使用C#检测IIS版本?
How to detect IIS version using C#?
更新:我的意思是从一个 winapp(实际上是开发一个自定义安装程序,想要检查已安装的 IIS 的版本以调用适当的 api)
Update: I meant from a winapp (actually the scenario is developing a custom installer that wants to check the version of the installed IIS to call the appropriate api's)
推荐答案
您可以从 SERVER_SOFTWARE
变量中获取此信息.它将返回以下内容:
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)
等
如果您使用的是 ASP.NET,则可以通过
If you're using ASP.NET, you can get this string via
Request.ServerVariables["SERVER_SOFTWARE"];
看来您必须查询注册表才能获取此信息.查看此页面以了解操作方法.
It seems that you will have to query the registry to get this information. Take a look at this page to see how.
这篇关于如何使用 C# 检测 IIS 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!