IIS7 – post #1

Tags: IIS, Longhorn

As I posted earlier, I upgraded IISLogs.com to run on Longhorn beta 2 and IIS7.  The previous deployment was IIS6 / ASP.Net 1.1.  I will try to post general feedback and my experiences mostly about IIS7.  These are my own opinions and don't represent Microsoft or any other company.   Here is some information about the machine running IIS7 and software installed.

Overview of software / machine setup

One thing I really like about IIS7 is the ability to select which "Role Services" (I think that is the right term) I want installed.  I did not install the items listed below.  Having the ability to select which items are installed reduces the chances of being exploited.  I wish this was available last month because I wouldn't have to worry about patching Classic ASP since it wouldn't have been installed.  🙂  You might wonder why I didn't install any authentication modules?  Simple, I don't need them.  In security, the less installed the more secure your server is.  (Less is more theory).  My server runs strictly .NET content.  The install was very clean, I used the GUI to become familiar with how everything works, plus I don't have scripts done yet.  🙂   All components installed cleanly however it took quite a while to complete.  I expect this type of performance since being a beta 2 product.  This is very stable and I'm excited to see what type of performance Longhorn will have at RTM.  It should be very fast!

Components I did not install

  • Static Content
  • ASP
  • CGI
  • Server Side Includes
  • Windows Authentication
  • Digest Authentication
  • Basic Authentication
  • Directory Browsing
  • Client Certificate Mapping Authentication
  • IIS Client Certificate Mapping Authentication

Other general thoughts and first impressions

Some other observations, I don't want to be too negative since I'm lucky to be able to run beta 2 live.  Overall, the product is very good for a beta 2 product, especially a server product.    My server is happy and everything is working.   The performance of installing stuff is slow but for the most part no errors happen.  That is a good thing.  I've been keeping a log of sorts on the desktop when I have questions or just a general observation.  If I really want to know the answer, posting a question on IIS.net is the place to go.  Many of the IIS.net product team hangs out there and answers your questions.   There is a lot, I mean a lot of content, webcasts, videos, examples and much more on IIS7.  I'm really impressed by the amount of documentation and examples available.  I strongly recommend anyone who wants to learn more about Longhorn and IIS7 to live in the TechCENTER portion of IIS.net. 

There are some new GUI tools that are taking some time to get used to.   The new IIS Manager is taking some time to get used to.  That is perfectly acceptable and I'm sure as new releases come out this will only get better.  I really like the new Server Manager, I seem to be using this a lot and is functional.  Check it out!  I absolutely "digg" the new perfomance monitor in Longhorn.  This could be an entire blog posting but let me say it is very useful!

One additional thing I really like is the ability to script out most everything.  I plan on publishing more scripts as I run IISLogs.com longer.  Here are a few I used to create my Site, Application Pool and web.config.  These are "hello world" type of scripts and not 100%.  One unique thing I'm trying is to embed all the logic into a web service so this could be published on any IIS7 server.  I'm not sure if that architecture will work or not.   This is beta and time to experiment to see if it will work or not.

Basic scripts – Search IIS.Net to find others IIS7 scripts, documentation. Note I write all my samples in VB but like readying C# better.  I can't write C# very well but don't mind reading C# samples. 🙂 

The webpage code – This is an advanced "hello world" example.  It implements a button with 4 textboxes to collect the necessary information. 🙂

 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style=’width: 365px; height: 241px’>
<tr>
<td style=’width: 100px’>
<asp:Label ID="Label1" runat="server" Text="Domain Name"></asp:Label></td>
<td style=’width: 100px’>
<asp:TextBox ID="txtDomainName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style=’width: 100px’>
<asp:Label ID="Label2" runat="server" Text="Protocol"></asp:Label></td>
<td style=’width: 100px’>
<asp:TextBox ID="txtProtocol" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style=’width: 100px’>
<asp:Label ID="Label3" runat="server" Text="Port"></asp:Label></td>
<td style=’width: 100px’>
<asp:TextBox ID="txtPort" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style=’width: 100px’>
<asp:Label ID="Label4" runat="server" Text="Directory Path"></asp:Label></td>
<td style=’width: 100px’>
<asp:TextBox ID="txtDirectoryPath" runat="server"></asp:TextBox></td>
</tr>
</table>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Create Site" /></div>
</form>
</body>
</html>

Code behind file

Imports Microsoft.Web.Administration
Partial Class Default2
    Inherits System.Web.UI.Page


    Sub AddSite()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myNewSite As New localhost.WebService
        myNewSite.AddSite(txtDomainName.Text, txtProtocol.Text, txtPort.Text, txtDirectoryPath.Text)
        myNewSite.AddNewAppPool(txtDomainName.Text, txtDirectoryPath.Text)
        myNewSite.SetConfigurationInSiteRoot(txtDomainName.Text)
    End Sub
End Class

The Web Service – This does all the work, it was run locally on the IIS7 machine

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports Microsoft.Web.Administration

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
     Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As String
        Return "Hello World"
    End Function

    <WebMethod(Description:="""Add New Site to IIS7 Server""")> _
    Public Function AddSite(ByVal DomainName As String, ByVal Protocol As String, ByVal Port As String, ByVal DirectoryPath As String) As String
        Try
            Dim NewSite As New ServerManager
            NewSite.Sites.Add(DomainName, Protocol, ":" & Port & ":", DirectoryPath)
            NewSite.Update()
            Return "Site Creation Succeeded"
        Catch ex As Exception
            Return "Site Creation failed"
        End Try
    End Function


    <WebMethod(Description:="""Add New Application Pool""")> _
    Public Function AddNewAppPool(ByVal DomainName As String, ByVal Path As String) As String
        Try
            Dim objSM As New ServerManager
            Dim objSite As Site = objSM.Sites(DomainName)
            objSite.Name = DomainName
            objSite.Applications(0).VirtualDirectories(0).PhysicalPath = Path
            objSM.ApplicationPools.Add(DomainName & "ApplicationPool")
            objSM.Sites(DomainName).Applications(0).ApplicationPoolName = DomainName & "ApplicationPool"

            Dim apppool As ApplicationPool = objSM.ApplicationPools(DomainName & "ApplicationPool")
            apppool.ManagedPipelineMode = ManagedPipelineMode.Integrated
            objSM.Update()
            apppool.Recycle()
            Return "App Pool Creation succeeded"
        Catch ex As Exception
            Return "App Pool Creation failed"
        End Try
    End Function

    <WebMethod(Description:="""Set Configuration in Root web.config""")> _
    Public Function SetConfigurationInSiteRoot(ByVal DomainName As String) As String
        Try

            Dim mgr As ServerManager = New ServerManager()
            Dim configMgr As ConfigurationManager = mgr.GetWebConfigurationManager(New WebConfigurationMap(), DomainName, "/")
            Dim section As ConfigurationSection = configMgr.GetSection("system.webServer/defaultDocument")
            Dim enabled As ConfigurationAttribute = section.GetAttribute("enabled")

            enabled.Value = True
            configMgr.Save()

            Return "Succeeded"
        Catch ex As Exception
            Return "Failed"

        End Try
    End Function

End Class

Web.config file 

<?xml version="1.0"?>
<configuration>
        <appSettings>
                <add key="localhost.WebService" value="http://localhost:49341/WebSite1/WebService.asmx"/>
         </appSettings>
        <system.web>
            <compilation debug="false">
                <assemblies>
                    <add assembly="Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                </assemblies>
            </compilation>
            <authentication mode="Windows"/>
        </system.web>
</configuration>
 

In conclusion, if you have made it this far I applaud you.  I encourage anyone looking for a rock solid, flexible web server IIS7 will definitely meet your needs.  If you have a chance to evaluate it now, I'd highly recommend. it.  I'm lucky to get an early start and as I become more familiar with IIS7 / Longhorn, I'll post here.  Happy Beta testing!

Steve Schofield
Windows Server MVP – IIS
ASPInsider Member – MCP

http://www.orcsweb.com/
Managed Complex Hosting
#1 in Service and Support