Share via


Edit Settings for Pages and Controls (IIS 7)

Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista

IIS 7 provides default settings for ASP.NET pages and controls, but you can change those settings as needed. For example, you can set the master page file for a site or enable view state.

Prerequisites

For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see Pages and Controls Feature Requirements (IIS 7).

Exceptions to feature requirements

  • None

To edit settings for pages and controls

You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.

User Interface

To Use the UI

  1. Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).

  2. In Features View, double-click Pages and Controls.

  3. On the Pages and Controls page, edit settings as necessary.

  4. When finished, click Apply in the Actions pane.

Command line

Enable or disable page output buffering

To enable or disable page output buffering, use the following syntax:

appcmd set config /commit:WEBROOT /section:pages /buffer:True|False

The variable buffer:True enables buffering of page output. The default is True.

Specify master page file

To specify a master page file, use the following syntax:

**appcmd set config /commit:WEBROOT /section:pages /masterPageFile:**string

The variable string is the name of the master page file.

Specify style sheet theme

To specify the style sheet to apply to a page, use the following syntax:

**appcmd set config /commit:WEBROOT /section:pages /styleSheetTheme:**string

The variable string is the name of the style sheet.

Specify page theme

To specify the name of the theme that is used for those pages that are in the scope of the configuration file, use the following syntax:

**appcmd set config /commit:WEBROOT /section:pages /theme:**string

The variable string is the name of the theme.

Enable or disable authenticated view state

To enable or disable message authentication checking (MAC) on a page's view state when the page is posted back from the client, use the following syntax:

appcmd set config /commit:WEBROOT /section:pages /enableViewStateMac:True|False

The variable enableViewStateMac:True enables authenticated view state. The default is True.

Enable or disable view state

To enable or disable view state for a page and for any server controls that are contained on the page, use the following syntax:

appcmd set config /commit:WEBROOT /section:pages /enableViewState:True|False

The variable enableViewState:True enables view state for a page. The default is True.

Set maximum page state field length

To set the maximum length of a page's state field, use the following syntax:

**appcmd set config /commit:WEBROOT /section:pages /maxPageStateFieldLength:**int

The variable int is the maximum length of a page's state field. When this is a positive number, the view state field sent to the browser is broken into pieces. The sum of all pieces is equal to the maximum length set. A negative number indicates that the view state should not be broken into pieces. The default value is -1.

Specify code-behind class for pages

By default, to specify the code-behind class that .aspx pages inherit, use the following syntax:

**appcmd set config /commit:WEBROOT /section:pages /pageBaseType:**string

The variable string is the name of the code-behind class for .aspx pages. The default is System.Web.UI.Page.

Specify code-behind class for controls

By default, to specify the code-behind class that user controls inherit, use the following syntax:

**appcmd set config /commit:WEBROOT /section:pages /userControlBaseType:**string

The variable string is the name of the code-behind class for user controls. The default is System.Web.UI.UserControl.

Set compilation mode

To specify whether pages are compiled or interpreted, use the following syntax:

appcmd set config /commit:WEBROOT /section:pages /compilationMode:Auto|Never|Always

The variable compilationMode:Auto sets ASP.NET so that it does not compile the page, if it is possible. The variable compilationMode:Never sets ASP.NET to never dynamically compile the page. If a page contains a script block or code construct that requires compilation, ASP.NET will return an error and the page will not run. The variable compilationMode:Always sets ASP.NET to always compile the page. The default is True.

Add a namespace

To add a namespace to the collection of namespaces that are used during pre-compilation, use the following syntax:

appcmd set config /commit:WEBROOT /section:pages /+"[namespace='string']"

The variable string is the namespace to add to the collection.

Remove a namespace

To remove a namespace from the collection of namespaces that are used during pre-compilation, use the following syntax:

appcmd set config /commit:WEBROOT /section:pages /-"[namespace='string']"

The variable string is the namespace to remove from the collection.

Enable or disable session state

To enable or disable view state, use the following syntax:

appcmd set config /commit:WEBROOT /section:pages /enableSessionState:True|False|ReadOnly

The variable enableViewState:ReadOnly indicates that the session state is not writable. The default is True.

Enable or disable request validation

To enable or disable the examination of all input by the browser for potentially dangerous content, use the following syntax:

appcmd set config /commit:WEBROOT /section:pages /validateRequest:True|False

The variable validateRequest:True enables request validation. The default is True.

Note

When you use Appcmd.exe to configure the <pages> element at the global level in IIS 7, you must specify /commit:WEBROOT in the command so that configuration changes are made to the root Web.config file instead of ApplicationHost.config.

For more information about Appcmd.exe, see Appcmd.exe (IIS 7).

Configuration

The procedure in this topic affects the following configuration elements:

<pages>

For more information about IIS 7 configuration, see IIS Settings Schema on MSDN.

WMI

Use the following WMI classes, methods, or properties to perform this procedure:

  • PagesSection class

For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS 7.0 Beta: IIS WMI Provider Reference on the MSDN site.

See Also

Concepts

Configuring Pages and Controls in IIS 7