Static Content <staticContent>

Overview

The <staticContent> element configures several settings related to processing requests for static files in Internet Information Services (IIS) 7.

The <staticContent> element contains the following three attributes that specify whether IIS 7 should apply a document footer to static files:

  • The enableDocFooter attribute specifies whether document footers are enabled.

  • The defaultDocFooter attribute contains either:

    • A text string that IIS 7 will use for the document footer if the isDocFooterFileName attribute is set to false
    • The fully-qualified path to a file that contains the text that IIS 7 will use for the document footer if the isDocFooterFileName attribute is set to true.
  • As noted above, the isDocFooterFileName attribute specifies whether the defaultDocFooter attribute contains a text string that IIS 7 will use for the document footer or the fully qualified path to a file that contains the text that IIS 7 will use for the document footer.

Note

By default, the isDocFooterFileName attribute is set to false and locked globally. To use files for document footers, you would need to either set the isDocFooterFileName attribute to true at the global-level, or unlock the attribute. To learn more about locking and unlocking attributes, see the How to Use Locking in IIS 7.0 Configuration walkthrough.

Compatibility

Version Notes
IIS 10.0 The <staticContent> element was not modified in IIS 10.0.
IIS 8.5 The <staticContent> element was not modified in IIS 8.5.
IIS 8.0 The <staticContent> element was not modified in IIS 8.0.
IIS 7.5 The <staticContent> element was not modified in IIS 7.5.
IIS 7.0 The <staticContent> element was introduced in IIS 7.0.
IIS 6.0 The <staticContent> element replaces the following IIS 6.0 metabase properties:
  • DefaultDocFooter
  • EnableDocFooter

Setup

The <staticContent> element is included in the default installation of IIS 7.

How To

There is no user interface for configuring the <staticContent> element for IIS 7. For examples of how to configure the <staticContent> element programmatically, see the Code Samples section of this document.

Configuration

Attributes

Attribute Description
defaultDocFooter Optional string attribute.

Specifies either the default footer text for every Web page on a site, or the path of a file that contains the default footer text. How IIS 7 uses this property depends on the value of the isDocFooterFileName attribute.

Note: The custom footer will only be sent if the enableDocFooter attribute is set to true.
enableDocFooter Optional Boolean attribute.

Specifies whether the text indicated by the defaultDocFooter attribute will appear on every static page on a Web site.

The default value is false.
isDocFooterFileName Optional Boolean attribute.

Specifies whether the string in the defaultDocFooter attribute contains a path of a file that contains the default footer text for every static Web page on a site.

The default value is false.

Child Elements

Element Description
clientCache Optional element.

Specifies settings for caching static content that is sent to the client.
mimeMap Optional element.

Specifies a list of the file name extensions for MIME mappings.

Configuration Sample

The following configuration sample enables a document footer for static content, and adds a simple copyright notice as the footer text.

<configuration>
   <system.webServer>
      <staticContent enableDocFooter="true"
         defaultDocFooter="The information in this web site is copyrighted." />
   </system.webServer>
</configuration>

Sample Code

The following code samples enable a document footer for static content, and add a simple copyright notice as the footer text.

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/staticContent /enableDocFooter:"True"

appcmd.exe set config "Default Web Site" -section:system.webServer/staticContent /defaultDocFooter:"The information in this web site is copyrighted."

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetWebConfiguration("Default Web Site");

         ConfigurationSection staticContentSection = config.GetSection("system.webServer/staticContent");
         staticContentSection["defaultDocFooter"] = @"The information in this web site is copyrighted.";
         staticContentSection["enableDocFooter"] = true;

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetWebConfiguration("Default Web Site")

      Dim staticContentSection As ConfigurationSection = config.GetSection("system.webServer/staticContent")
      staticContentSection("defaultDocFooter") = "The information in this web site is copyrighted."
      staticContentSection("enableDocFooter") = True

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Default Web Site";

var staticContentSection = adminManager.GetAdminSection("system.webServer/staticContent", "MACHINE/WEBROOT/APPHOST/Default Web Site");
staticContentSection.Properties.Item("defaultDocFooter").Value = "The information in this web site is copyrighted.";
staticContentSection.Properties.Item("enableDocFooter").Value = true;

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Default Web Site"

Set staticContentSection = adminManager.GetAdminSection("system.webServer/staticContent", "MACHINE/WEBROOT/APPHOST/Default Web Site")
staticContentSection.Properties.Item("defaultDocFooter").Value = "The information in this web site is copyrighted."
staticContentSection.Properties.Item("enableDocFooter").Value = True

adminManager.CommitChanges()