Click here to Skip to main content
15,895,799 members
Articles / Web Development / IIS

Using Managed Code to Detect if IIS is Installed and ASP/ASP.NET is Registered

Rate me:
Please Sign up or sign in to vote.
4.60/5 (15 votes)
30 Dec 2007CPOL4 min read 192.5K   2.6K   75  
Explains how to use managed code to detect which version of Internet Information Services (IIS) is installed and if ASP or ASP.NET is registered.
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- 
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="DownloadInfoConnectionClosed" xml:space="preserve">
    <value>Could not download {0} - FTP server closed the connection.</value>
  </data>
  <data name="DownloadInfoInvalidResponseReceived" xml:space="preserve">
    <value>Could not download {0} - a web page was returned from the web server.</value>
  </data>
  <data name="FileDownloaderCancelled" xml:space="preserve">
    <value>Download was cancelled.</value>
  </data>
  <data name="FileDownloaderDownloadLocation" xml:space="preserve">
    <value>Downloading file to {0}.</value>
  </data>
  <data name="Format_BadDatePattern" xml:space="preserve">
    <value>Could not determine the order of year, month, and date from '{0}'.</value>
  </data>
  <data name="Format_BadDateTime" xml:space="preserve">
    <value>String was not recognized as a valid DateTime.</value>
  </data>
  <data name="Format_BadDateTimeCalendar" xml:space="preserve">
    <value>The DateTime represented by the string is not supported in calendar {0}.</value>
  </data>
  <data name="Format_BadDayOfWeek" xml:space="preserve">
    <value>String was not recognized as a valid DateTime because the day of week was incorrect.</value>
  </data>
  <data name="Format_BadFormatSpecifier" xml:space="preserve">
    <value>Format specifier was invalid.</value>
  </data>
  <data name="Format_BadQuote" xml:space="preserve">
    <value>Cannot find a matching quote character for the character '{0}'.</value>
  </data>
  <data name="Format_DateOutOfRange" xml:space="preserve">
    <value>The DateTime represented by the string is out of range.</value>
  </data>
  <data name="Format_EmptyInputString" xml:space="preserve">
    <value>Input string was either empty or contained only white space.</value>
  </data>
  <data name="Format_ExtraJunkAtEnd" xml:space="preserve">
    <value>Additional non-parsable characters are at the end of the string.</value>
  </data>
  <data name="Format_NeedSingleChar" xml:space="preserve">
    <value>String must be exactly one character long.</value>
  </data>
  <data name="Format_RepeatDateTimePattern" xml:space="preserve">
    <value>DateTime pattern '{0}' appears more than once with different values.</value>
  </data>
  <data name="Format_TwoTimeZoneSpecifiers" xml:space="preserve">
    <value>The String being parsed cannot contain two TimeZone specifiers.</value>
  </data>
  <data name="Format_UnknowDateTimeWord" xml:space="preserve">
    <value>The string was not recognized as a valid DateTime. There is a unknown word starting at index {0}.</value>
  </data>
  <data name="ArgumentNull_String" xml:space="preserve">
    <value>String reference not set to an instance of a String.</value>
  </data>
  <data name="Format_InvalidLen" xml:space="preserve">
    <value>String was not of correct length.</value>
  </data>
  <data name="Format_InvalidString" xml:space="preserve">
    <value>Input string was not in a correct format.</value>
  </data>
  <data name="Argument_MustBeIsoDateTime" xml:space="preserve">
    <value>Argument must be an IsoDateTime.</value>
  </data>
  <data name="Argument_EnumIllegalVal" xml:space="preserve">
    <value>Illegal enum value: {0}.</value>
  </data>
  <data name="Argument_InvalidEnumValue" xml:space="preserve">
    <value>The value '{0}' is not valid for this usage of the type {1}.</value>
  </data>
  <data name="Argument_InvalidFlag" xml:space="preserve">
    <value>Value of flags is invalid.</value>
  </data>
  <data name="Argument_InvalidIndexValuesString" xml:space="preserve">
    <value>The starting index and ending index refer to the same location in the string.</value>
  </data>
  <data name="Argument_StartIndexGreaterThanEndIndexString" xml:space="preserve">
    <value>The starting index refers to a location in the string that is after the ending index.</value>
  </data>
  <data name="ArgumentOutOfRange_IndexLessThanLength" xml:space="preserve">
    <value>Index must be less than the length of string.</value>
  </data>
  <data name="ArgumentOutOfRange_IndexLessThanZero" xml:space="preserve">
    <value>Index must be non-negative.</value>
  </data>
  <data name="ArgumentOutOfRange_IndexString" xml:space="preserve">
    <value>Index was out of range. Must be non-negative and less than the length of the string.</value>
  </data>
  <data name="InvalidCast_FromTo" xml:space="preserve">
    <value>Invalid cast from '{0}' to '{1}'.</value>
  </data>
  <data name="MDA_InvalidFormatForLocal" xml:space="preserve">
    <value>Cannot apply format "{0}" to the date "{1}" as the date is already in local time.</value>
  </data>
  <data name="MDA_InvalidFormatForUtc" xml:space="preserve">
    <value>Cannot apply format "{0}" to the date "{1}" as the date is already in universal time.</value>
  </data>
  <data name="Argument_StringZeroLength" xml:space="preserve">
    <value>String cannot be of zero length.</value>
  </data>
  <data name="Argument_NotSerializable" xml:space="preserve">
    <value>Argument passed in is not serializable.</value>
  </data>
  <data name="Argument_MustBeDateTime" xml:space="preserve">
    <value>Object must be of type DateTime.</value>
  </data>
  <data name="Argument_MustBeString" xml:space="preserve">
    <value>Object must be of type String.</value>
  </data>
  <data name="Argument_MustBeAttribute" xml:space="preserve">
    <value>Argument must be an Attribute or derived from an Attribute.</value>
  </data>
  <data name="Format_Dns_Bad_Ip_Address" xml:space="preserve">
    <value>An invalid IP address was specified.</value>
  </data>
</root>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
I am a Microsoft C# MVP, author, speaker, blogger, and software developer. I also created the WP Requests and WinStore Requests sites for Windows Phone and Windows Sotre apps as well as several open source projects.

I've been involved with computers in one way or another for as long as I can remember, but started professionally in 1993. Although my primary focus right now is commercial software applications, I prefer building infrastructure components, reusable shared libraries and helping companies define, develop and automate process and code standards and guidelines.

Comments and Discussions