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

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

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

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

 

转载于:https://www.cnblogs.com/zrx401558287/archive/2009/06/02/1494775.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值