If a document name is not specified on the URL, IIS can be configured to automatically determine the intended document, as shown in Figure 9.11.
In addition, you can configure IIS to attach an HTML footer to all documents transferred from your Web server to the client browser. This can be especially handy for navigation bars, copyright notices, or other legal information.
To save the user from having to know the main document for your site, you can specify the name of the document to be returned to the client when the filename is omitted from the URL.
To enable this functionality, two properties must be configured: EnableDefaultDoc and DefaultDoc . EnableDefaultDoc is a Boolean value describing whether the default document list should be checked or not. DefaultDoc is a comma-delimited list stored as a string (not in a variant array) that lists the names of documents that will be sought when the user does not specify a filename in the URL. Together, these two properties allow the user to enter a site without typing or even knowing the particular filename.
To find if a default document is in use for a specific site, use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.EnableDefaultDoc
To set a new value for EnableDefaultDoc , use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim EnableDefaultDocument As Boolean ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value EnableDefaultDocument = True Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.EnableDefaultDoc = EnableDefaultDocument Resource.SetInfo
To find the default documents used for a particular site, use the following Visual Basic code to return a comma-delimited list of files:
Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.DefaultDoc
To set a new default document for a site, use the following Visual Basic code to pass in a comma-delimited list of documents. The order is important in the list; it determines the order in which IIS will look for the default document if more than one file in the list exists in the file system directory.
Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim DefaultDocument As String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value DefaultDocument = "default.asp,default.htm,index.html" Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.DefaultDoc = DefaultDocument Resource.SetInfo
The document footer allows the administrator to attach an HTML-format file to all outbound HTML files from the server. This can be especially handy for navigation tool bars, legal notices, or even contact information. Unlike the DefaultDoc list, only a single file is used, and the full physical path to the file is specified in the DefaultDocFooter property.
After the DefaultDocFooter property populates the path to the HTML file, you can enable the footer by setting the EnableDocFooter property to True.
To find the name of the HTML file attached to all HTML page requests , use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.DefaultDocFooter
To establish a default document footer for a site, use the following Visual Basic code:
Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim DefaultDocumentFooter As String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value DefaultDocumentFooter = "c:\legal_footers\copyright.htm" Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.DefaultDocFooter = DefaultDocumentFooter Resource.SetInfo
To query whether or not the document footer is enabled for a site, use the following Visual Basic code to return a Boolean value representing the status of the property:
Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.EnableDocFooter
After establishing the name of the HTML file to be used, you must enable the use of the document footer by setting the EnableDocFooter to True if you want to attach a footer to HTML page requests. Use the following Visual Basic code to perform this task:
Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim EnableDocumentFooter As Boolean ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value EnableDocumentFooter = True Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.EnableDocFooter = EnableDocumentFooter Resource.SetInfo
Top |