如何判断IIS版本 判断IIS中.NET2.0是否注册

http://www.codeproject.com/KB/cs/iisdetection.aspx

      今天在codeproject上闲逛发现这篇很有用的文章,因为以前的项目安装的时候要装webservice,那时经常出现iis中没有注册.NET2.0的问题,现在在安装的时候就可以直接判断IIS版本和.NET是否在IIS中注册了.

如何判断IIS版本 判断IIS中.NET2.0是否注册

using  System;
using  System.Collections.Generic;
using  System.Text;

using  Campari.Software;

namespace  Tester
{
    
class  Program
    {
        
static   void  Main( string [] args)
        {
            
bool  iis4Installed  =  
                InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS4);

            
bool  iis5Installed  =
                InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS5);

            
bool  iis51Installed  =
                InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS51);

            
bool  iis6Installed  =
                InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS6);

            
bool  iis7Installed  =
                InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS7);


            Console.WriteLine(
" IIS 4 installed? {0} " , iis4Installed);
            Console.WriteLine(
" IIS 5 installed? {0} " , iis5Installed);
            Console.WriteLine(
" IIS 5.1 installed? {0} " , iis51Installed);
            Console.WriteLine(
" IIS 6 installed? {0} " , iis6Installed);
            Console.WriteLine(
" IIS 7 installed? {0} " , iis7Installed);

            
if  (iis4Installed  ||  iis5Installed  ||  iis51Installed  ||  iis6Installed  ||  iis7Installed)
            {
                Console.WriteLine(
" ASP Registered? {0} " ,
                    InternetInformationServicesDetection.IsAspRegistered());

                Console.WriteLine(
" ASP.NET 1.0 Registered? {0} " ,
                    InternetInformationServicesDetection.IsAspNetRegistered(FrameworkVersion.Fx10));

                Console.WriteLine(
" ASP.NET 1.1 Registered? {0} " ,
                    InternetInformationServicesDetection.IsAspNetRegistered(FrameworkVersion.Fx11));

                Console.WriteLine(
" ASP.NET 2.0 Registered? {0} " ,
                    InternetInformationServicesDetection.IsAspNetRegistered(FrameworkVersion.Fx20));

                
//  These really don't exist, they are actually the .NET 2.0 version of ASP.NET.
                Console.WriteLine( " ASP.NET 3.0 Registered? {0} " ,
                    InternetInformationServicesDetection.IsAspNetRegistered(FrameworkVersion.Fx30));

                Console.WriteLine(
" ASP.NET 3.5 Registered? {0} " ,
                    InternetInformationServicesDetection.IsAspNetRegistered(FrameworkVersion.Fx35));
            }

            Console.WriteLine();

            Console.ReadLine();
        }
    }
}

附代码:

/Files/zrx401558287/MSNET20.zip

 

你可能感兴趣的:(.net)