Showing posts with label IIS Administration. Show all posts
Showing posts with label IIS Administration. Show all posts

Friday, July 27, 2007

Tuesday, May 29, 2007

ASPBufferingLimit - IIS5 vs. IIS6

On upgrading a web server from Win2K/IIS5 to Win2K3/IIS6, an old classic ASP application stopped working. This app pulled a large recordset from a SQL database, dumped the records into a large array, and then looped through the array, rendering a grid. I'm not sure why it needed the intermediate step, but of course the developer was long gone from the company. Such is life. Here's the error encountered:


First I ruled out the most obvious and usual offenders during a migration - code and data. Configuring the app on my development machine (IIS5), pulling down the production code and pointing to the production db, the app functioned swimmingly.

Moving on, I researched and came across an IIS ADSI property, "ASPBufferingLimit". Apparently IIS6 sets a lower constraint on the ASP Buffer than IIS5. Good for a healthy web server, but bad for some legacy apps.

The issue was resolved by upping the buffer limit on the IIS6 server. The server administrator accomplished this by running:

    c:\inetpub\adminscripts\adsutil.vbs set w3svc/aspbufferinglimit value
Note: The default setting in IIS6 is ~4MB. The default setting in IIS5 is not visible, apparently, but is rumored to be ~128MB. That seems high to me but I have no choice other than to trust google research :)

Friday, May 25, 2007

Enable IIS 6.0 Extensions using VBScript

If you've worked with IIS 5 and IIS 6, you know that IIS 6 has some tighter default security settings. For example, an administrator must take explicit steps to enable the server execution of ASP/ASP.NET applications. This is accomplished with a few quick clicks, but I'm always looking for shortcuts, e.g.

    Set IIsWebServiceObj = GetObject("IIS://localhost/W3SVC")IIsWebServiceObj.EnableWebServiceExtension "ASP.NET v1.1.4322" IIsWebServiceObj.SetInfo
Taking it a step further, suppose you have a proprietary extension, for instance a dll or exe which serves as an engine to render dynamic html. In other words, say you have a very OLD application. Here's how you would handle that wrinkle:

    Option explicit
    dim IIsWebServiceObj

    Set IIsWebServiceObj = GetObject("IIS://localhost/W3SVC")

    'Enable Proprietary Extention
    IISWebServiceObj.AddExtensionFile "c:\mydll.dll", true, "MyDLL", true, _ "MyProprietaryExtensions"
    IIsWebServiceObj.SetInfo

    wscript.echo "success!"

Friday, March 23, 2007

IE Web Controls - Tree View - Client Scripts

The IEWC Tree View component is useful if you are writing an ASP.NET 1.1 application and need to display a relatively large collapsible hierarchy (tree structure).

During installation (addressed in an earlier blog), a "/webctrl_client" directory is added to your default web site (c:\inetpub\wwwroot\webctrl_client). By default, the treeview component uses this location to reference the client-side scripts for image rendering and click behavior.

If you have a shared server environment with multiple web sites (Win2k Server or Win2k3 server), you have to copy this webctrl_client folder to the home directories of each site using the controls.

Alternatively, you can define a custom location in your web.config. This would allow you to set up a virtual directory and maintain the webctrl_client stuff in a SINGLE PLACE.

Here is close to the syntax to add to your web.config, directly within the section.

<configSections>
<section name="MicrosoftWebControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0,Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
</configSections>

<MicrosoftWebControls>
<add key="CommonFiles" value="/iistreeprint.net/webctrl_client/1_0/" />
</MicrosoftWebControls>

Tuesday, March 20, 2007

Programmatic IIS Administration - Selecting a Virtual Directory

This is a followup to an earlier post, Selecting a Site. The following function will return a virtual directory object, which you can then manipulate (set Directory Security options, ASP.NET version, etc.)


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This sub will pass back a VirtualDirectory from a given Website Name, Virtual Directory Child 'Name
' Paramters: WebSite = Website Name
' VirDirName = Virtual Directory Name
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function GetVirtualDirectory(WebSite,VirDirName)

dim adspath,rootobj,WebSiteObj

set WebSiteObj=GetWebSiteByName(WebSite)
set rootObj=getObject(WebSiteObj.adsPath&"/root")

adspath=rootobj.adspath

set GetVirtualDirectory=getObject(adspath&"/"&VirDirName)

end function

Monday, March 19, 2007

Assign an Application Pool using VBScript

The following script will assign a given IIS object (site or virtual directory) to an existing application pool.

Note that it relies on a helper function to check if the pool exists.

It also makes sure that the current machine is Win2003 -- you can't specify pools in prior OS's. This OS check function was detailed in a previous blog


'****************************************************************************************** ' Name: SetAppPool
' Description: Assign the IIS Object to an Application Pool (IIS 6 only)
' Inputs: ObjApp (IIS Object), strAppPool (Pool to assign to)
'******************************************************************************************
sub SetAppPool(ObjApp, strAppPool)
if instr(GetOS_Remote("."), "2K3") <> 0 then
if AppPoolExists(strAppPool) then
ObjApp.AppPoolId = strAppPool
ObjApp.SetInfo
logmsg "Set App Pool to " & strAppPool
else
logmsg "Error: App Pool " & strAppPool & " Not Found"
end if
else
logmsg "Skip app pool setting; not a 2003 server"
end if
end sub

'******************************************************************************************
' Name: AppPoolExists
' Description: See if the application pool exists (IIS 6 only)
' Inputs: strAppPool
'******************************************************************************************
function AppPoolExists(strAppPool)
dim objPool
on error resume next
Set objPool = GetObject("IIS://localhost/w3svc/AppPools/" & strAppPool)
if err.number <> 0 then
AppPoolExists = false
else
AppPoolExists = true
end if
end function

Wednesday, March 14, 2007

Programmatic IIS Administration - Selecting a Site

Configuring a web server can be complicated, particularly if it is running multiple web sites, with multiple virtual directories under each site. Such a complex IIS tree requires many, many mouse clicks in order to configure according to specifications.

And what happens if the server catches on fire? It may be a good idea to script the configuration. VBScript and the IIS ADSI objects offer a multitude of possibilities.

Here is a simple VBscript function for selecting a site by name (which you can then configure with proper directory security, isolation level, host headers, etc...)

Function GetWebSiteByName(WebSiteName)
dim rootObj,count,website
set rootObj=GetObject("IIS://LocalHost/W3SVC")

for each website in rootObj
if LCase(website.class) = LCase("IIsWebServer") then
if LCase(website.ServerComment)=LCase(WebSiteName) then
set GetWebSiteByName=website
exit function
end if
end if
next

end Function

Refer back for more Automated IIS Administration examples, using low-tech script :)