Jerry Orman

Adventures in SharePoint

ASP.NET tab forces restart of W3SVC

ASP.NET tab forces restart of W3SVC

Rate This
  • Comments 5

If you change the version on the ASP.NET tab that comes with the 2.0 Framework, the entire W3SVC process restarts.  If you make this type of change during a maintenance window, the impact may not be too bad, but if you have multiple application pools in IIS and need to make this type of change during the day, all the application pools will recycle.

You can avoid this problem by running the following commands.  The first command configures the mappings in IIS and uses the -norestart command to tell aspnet_regiis to not restart the W3SVC service.  The second command restarts the IIS Application Pool:

    1. %windir%\Microsoft.Net\Framework\<version>\aspnet_regiis -s <path> -norestart
    2. %windir%\system32\iisapp.vbs /a <app pool> -r

It's important to note that it is not supported to run both 1.1 and 2.0 framework in the same application pool.  For example, you can't have /MyApp mapped to the 1.1 framework in an application pool called MyAppPool and also have /AnotherApp mapped to the 2.0 framework in the same application pool.  The symptom you will see is a Server Application Unavailable message in the browser.  You will also get the following event in the Application Event Log:

Event Type: Error
Event Source: ASP.NET 2.0.50727.0  <could also be 1.1.4322>
Event ID: 1062
Description:
It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process.

This requires that you know the IIS metabase path to the app; something like /w3svc/1/root/myapp if the application is under Default Web Site.  You also have to know the application pool which would require you to look it up in IIS.

I've attached a .vbs file that helps to automate this process.  Feel free to modify it however you see fit.  It takes in the name of the web site; i.e. "Default Web Site", the version of the framework you want to map, and the virtual path to the app you want to configure.  It's much easier to remember "Default Web Site" or "Intranet", than it is to remember the instance number of 578954321 :)

Example command lines:

  •   Configure the Default Web Site for ASP.NET 2.0
         ASPNETMapping_norestart.vbs website "Default Web Site" version 2.0
  •   Configure the Default Web Site for ASP.NET 1.1
         ASPNETMapping_norestart.vbs website "Default Web Site" version 1.1
  •   Configures the /mywebapp application for ASP.NET 2.0
         ASPNETMapping_norestart.vbs website "Default Web Site" apppath "/mywebapp" version 2.0
  •   Configures the /anotherapp application on the web site named Intranet for 2.0
         ASPNETMapping_norestart.vbs website "Intranet" apppath "/anotherapp" version 2.0

Download the file here

Attachment: ASPNETMapping_norestart.zip
  • PingBack from http://blog.cwa.me.uk/2007/02/27/the-evil-aspnet-tab-and-other-adventures-with-mmc/

  • Can you tell it what app pool you want the new app to be created in?

    ie If you have an existing one, and don't want to create a new one?

  • Recently we have discovered an issue with IIS Manager wherein changing settings in a certain way may

  • Recently we have discovered an issue with IIS Manager wherein changing settings in a certain way may

  • Thanks for this nice script, it helps to keep visitors happy!

    I fixeda bug for european users and added support for 4.0 framework:

    Option Explicit

    Dim objWebService       'Holds ADSI object for the W3SVC node

    Dim strWebSite          'Holds the website being investigated

    Dim strAppPath          'Virtual path to an application - left empty for the entire site

    Dim strAppPool          'Holds the name of the app pool for the application

    Dim strIISPath          'Path to the application in the metabase

    Dim strServer           'Name of the server - always localhost

    Dim strVersion          'Version of the framework - always 1.1 or 2.0

    Dim boolHelp            'Determine if help needs to be displayed

    Dim WshShell            'WSH object

    Dim objargs             'Command-line arguments

    Dim num                 'Store number of arguments

    Dim k                   'Counter for a loop

    'Get the command-line arguments

    Set objargs= WScript.Arguments

    num = objargs.Count

    'If there are no arguments, set boolHelp = 1

    If num = 0 Then

    boolHelp = 1

    End If

    'Loop through the arguments and pull out the web site name, the application path and the framework version

    For k = 0 To num - 1

      Select Case LCase(objargs.Item(k))

          Case "website"

              strWebSite = objargs.Item(k+1)

          Case "apppath"

              strAppPath = objargs.Item(k+1)

          Case "version"

              strVersion = objargs.Item(k+1)

      End Select

    Next

    'If there is no web site or arguments, display the help

    If strWebSite = "" Or strVersion = "" Or boolHelp = 1 Then

       WriteHelp

    'If everything is entered continue

    Else

       'Set Server to localhost

       strServer = "localhost"

       'Get the local web service node from IIS

       Set objWebService = GetObject( "IIS://" & strServer & "/W3SVC" )

       'Call EnumWebsites to loop through the web sites

       EnumWebsites objWebService

       'Create WScript.Shell object to run aspnet_regiis and iisapp

       Set WshShell = WScript.CreateObject("WScript.Shell")

       'Sub that calls aspnet_regiis with the -s and -norestart option

       ConfigureASPNet

       'Sub that calls IISapp.vbs to restart the app pool

       RestartAppPool

    End If

    'Takes in the web service ADSI object

    Sub EnumWebsites( objWebService )

       'Local to hold a web server object

       Dim objWebServer

       'Loop through the web servers found in the service

    For Each objWebServer In objWebService

    'Check if the web server object is of type "IIsWebServer"

           If objWebserver.Class = "IIsWebServer" Then

               'Is the webserver object the one we're wanting to configure?

               'If so, set the strIISPath and the application pool

    If LCase(objWebServer.ServerComment) = LCase(strWebSite) Then

    'Build out a path to the application

    strIISPath = "W3SVC/" & objWebserver.Name & "/ROOT" & strAppPath

    'Get the application object for the path you're wanting to configure

    Dim objwebapp

    Set objwebapp = GetObject("IIS://" & strServer & "/" & strIISPath)

    'Get the app pool for the application

    strAppPool = objwebapp.AppPoolID

       End If

           End If

       Next

    End Sub

    'Call the aspnet_regiis for the ASP.NET version passed in the command-line

    Sub ConfigureASPNET()

    Dim WShellReturn

    Select Case strVersion

       Case "4.0"

           WShellReturn = WshShell.Run("%windir%\Microsoft.Net\Framework\v4.0.30319\aspnet_regiis -s " & strIISPath & " -norestart", 1, true)  

           WScript.Echo "\Microsoft.Net\Framework\v4.0.30319\aspnet_regiis -s " & strIISPath & " -norestart"

       Case "2.0"

           WShellReturn = WshShell.Run("%windir%\Microsoft.Net\Framework\v2.0.50727\aspnet_regiis -s " & strIISPath & " -norestart", 1, true)  

           WScript.Echo "\Microsoft.Net\Framework\v2.0.50727\aspnet_regiis -s " & strIISPath & " -norestart"

       Case "1.1"

           WShellReturn = WshShell.Run("%windir%\Microsoft.Net\Framework\v1.1.4322\aspnet_regiis -s " & strIISPath & " -norestart", 1, true)  

           WScript.Echo "\Microsoft.Net\Framework\v1.1.4322\aspnet_regiis -s " & strIISPath & " -norestart"

    End Select

    'Check the return value and display a message if it failed.

    If WShellReturn <> 0 Then

       WScript.Echo "ASP.NET Registration Failed"

    Else

       WScript.Echo "Configured ASP.NET version " & strVersion

    End If

    End Sub

    'Restart the application pool identified from EnumWebsites

    Sub RestartAppPool()

    Dim WShellReturn

    WShellReturn = WshShell.Run("iisapp.vbs /a " & strAppPool & " /r", 1, true)

    WScript.Echo "Restarted app pool " & strAppPool

    End Sub

    'Write out the help

    Sub WriteHelp()

    WScript.Echo "Command line syntax:" & vbcrlf

    WScript.Echo "ASPNETMapping_norestart.vbs website <Name of site> AppPath <virtual path to app> server <servername>" & vbcrlf & vbcrlf

    WScript.Echo "Version can be 1.1, 2.0 or 4.0" & vbcrlf

    WScript.Echo "Examples:" & vbcrlf

    WScript.Echo "  Configure the Default Web Site for ASP.NET 2.0"

    WScript.Echo "     ASPNETMapping_norestart.vbs website " & Chr(34) & "Default Web Site" & Chr(34) & " version 2.0" & vbcrlf

    WScript.Echo "  Configure the Default Web Site for ASP.NET 1.1"

    WScript.Echo "     ASPNETMapping_norestart.vbs website " & Chr(34) & "Default Web Site" & Chr(34) & " version 1.1" & vbcrlf

    WScript.Echo "  Configures the /mywebapp application for ASP.NET 2.0"

    WScript.Echo "     ASPNETMapping_norestart.vbs website " & Chr(34) & "Default Web Site" & Chr(34) & " apppath " & Chr(34) & "/mywebapp" & Chr(34) & "version 2.0"

    End Sub

Page 1 of 1 (5 items)
Leave a Comment
  • Please add 6 and 5 and type the answer here:
  • Post