Este artículo se tradujo de forma manual. Mueva el puntero sobre las frases del artículo para ver el texto original. |
Traducción
Original
|
PagesSection (Clase)
Proporciona acceso mediante programación a la sección páginas del archivo de configuración. Esta clase no puede heredarse.
System.Configuration.ConfigurationElement
System.Configuration.ConfigurationSection
System.Web.Configuration.PagesSection
Ensamblado: System.Web (en System.Web.dll)
El tipo PagesSection expone los siguientes miembros.
| Nombre | Descripción | |
|---|---|---|
|
PagesSection | Infraestructura. Inicializa una nueva instancia de la clase PagesSection utilizando opciones predeterminadas. |
| Nombre | Descripción | |
|---|---|---|
|
AsyncTimeout | Obtiene o establece un valor que indica el número de segundos durante el que, en el procesamiento asincrónico de páginas, se va a esperar a que un controlador asincrónico finalice. |
|
AutoEventWireup | Obtiene o establece un valor que indica si los eventos para las páginas ASP.NET se conectan automáticamente a las funciones de control de eventos. |
|
Buffer | Obtiene o establece un valor que especifica si las páginas .aspx y los controles .ascx usan el almacenamiento en búfer de respuestas. |
|
ClientIDMode | Obtiene o establece el algoritmo predeterminado que se utiliza para generar el identificador de un control. |
|
CompilationMode | Obtiene o establece un valor que determina la forma de compilar las páginas .aspx y controles .ascx. |
|
ControlRenderingCompatibilityVersion | Obtiene o establece un valor que especifica la versión de ASP.NET compatible con cualquier elemento HTML representado. |
|
Controls | Obtiene una colección de objetos TagPrefixInfo. |
|
CurrentConfiguration | Obtiene una referencia a la instancia de Configuration de nivel superior que representa la jerarquía de configuración a la que pertenece la instancia actual de ConfigurationElement. (Se hereda de ConfigurationElement). |
|
ElementInformation | Obtiene un objeto ElementInformation que contiene la funcionalidad e información no personalizable del objeto ConfigurationElement. (Se hereda de ConfigurationElement). |
|
ElementProperty | Obtiene el objeto ConfigurationElementProperty que representa al propio objeto ConfigurationElement. (Se hereda de ConfigurationElement). |
|
EnableEventValidation | Obtiene o establece un valor que especifica si se ha habilitado la validación de eventos. |
|
EnableSessionState | Obtiene o establece un valor que especifica si estado de sesión está habilitado, deshabilitado o es de sólo lectura. |
|
EnableViewState | Obtiene o establece un valor que indica si el estado de vista está habilitado o deshabilitado. |
|
EnableViewStateMac | Obtiene o establece un valor que especifica si ASP.NET debe ejecutar un código de autenticación de mensaje (MAC) en el estado de vista de la página cuando el cliente devuelve la página. |
|
EvaluationContext | Obtiene el objeto ContextInformation para el objeto ConfigurationElement. (Se hereda de ConfigurationElement). |
|
IgnoreDeviceFilters | Obtiene la colección de etiquetas de dispositivo que ASP.NET debe omitir cuando representa una página. |
|
Item[ConfigurationProperty] | Obtiene o establece una propiedad o atributo de este elemento de configuración. (Se hereda de ConfigurationElement). |
|
Item[String] | Obtiene o establece una propiedad, un atributo o un elemento secundario de este elemento de configuración. (Se hereda de ConfigurationElement). |
|
LockAllAttributesExcept | Obtiene la colección de atributos bloqueados. (Se hereda de ConfigurationElement). |
|
LockAllElementsExcept | Obtiene la colección de elementos bloqueados. (Se hereda de ConfigurationElement). |
|
LockAttributes | Obtiene la colección de atributos bloqueados. (Se hereda de ConfigurationElement). |
|
LockElements | Obtiene la colección de elementos bloqueados. (Se hereda de ConfigurationElement). |
|
LockItem | Obtiene o establece un valor que indica si el elemento está bloqueado. (Se hereda de ConfigurationElement). |
|
MaintainScrollPositionOnPostBack | Obtiene o establece un valor que indica si la posición del desplazamiento de página se debe mantener cuando se vuelve de una devolución de datos del servidor. |
|
MasterPageFile | Obtiene o establece una referencia a la página maestra de la aplicación. |
|
MaxPageStateFieldLength | Obtiene o establece el número máximo de caracteres que puede contener un único campo de estado de vista. |
|
Namespaces | Obtiene una colección de objetos NamespaceInfo. |
|
PageBaseType | Obtiene o establece un valor que especifica una clase subyacente que las páginas .aspx heredan de manera predeterminada. |
|
PageParserFilterType | Obtiene o establece un valor que especifica el tipo de filtro del analizador. |
|
Properties | Obtiene la colección de propiedades. (Se hereda de ConfigurationElement). |
|
RenderAllHiddenFieldsAtTopOfForm | Obtiene o establece un valor que indica si todos los campos ocultos generados por el sistema se representan en la parte superior del formulario. |
|
SectionInformation | Obtiene un objeto SectionInformation que contiene la funcionalidad e información no personalizable del objeto ConfigurationSection. (Se hereda de ConfigurationSection). |
|
SmartNavigation | Obtiene o establece un valor que indica si las navegaciones inteligentes están habilitadas. |
|
StyleSheetTheme | Obtiene o establece el nombre de un tema de hoja de estilos de ASP.NET. |
|
TagMapping | Obtiene una colección de objetos TagMapInfo. |
|
Theme | Obtiene o establece el nombre de un tema de página ASP.NET. |
|
UserControlBaseType | Obtiene o establece un valor que especifica una clase subyacente que los controles de usuario heredan de manera predeterminada. |
|
ValidateRequest | Obtiene o establece un valor que determina si ASP.NET busca valores peligrosos en las entradas que provienen del explorador. Para obtener más información, vea Información general sobre los ataques mediante scripts. |
|
ViewStateEncryptionMode | Obtiene o establece el modo del cifrado que ASP.NET utiliza cuando mantiene los valores ViewState. |
| Nombre | Descripción | |
|---|---|---|
|
DeserializeElement | Lee XML del archivo de configuración. (Se hereda de ConfigurationElement). |
|
DeserializeSection | Infraestructura. Lee XML del archivo de configuración. (Se hereda de ConfigurationSection). |
|
Equals | Compara la instancia actual de ConfigurationElement con el objeto especificado. (Se hereda de ConfigurationElement). |
|
Finalize | Permite que un objeto intente liberar recursos y realizar otras operaciones de limpieza antes de ser reclamado por la recolección de elementos no utilizados. (Se hereda de Object). |
|
GetHashCode | Obtiene un valor único que representa la instancia actual de ConfigurationElement. (Se hereda de ConfigurationElement). |
|
GetRuntimeObject | Devuelve un objeto personalizado cuando se reemplaza en una clase derivada. (Se hereda de ConfigurationSection). |
|
GetTransformedAssemblyString | Devuelve la versión transformada del nombre de ensamblado especificado. (Se hereda de ConfigurationElement). |
|
GetTransformedTypeString | Devuelve la versión transformada del nombre de tipo especificado. (Se hereda de ConfigurationElement). |
|
GetType | Obtiene el objeto Type de la instancia actual. (Se hereda de Object). |
|
Init | Establece el objeto ConfigurationElement en su estado inicial. (Se hereda de ConfigurationElement). |
|
InitializeDefault | Se utiliza para inicializar un conjunto predeterminado de valores para el objeto ConfigurationElement. (Se hereda de ConfigurationElement). |
|
IsModified | Indica si se ha modificado este elemento de configuración desde la última vez en que se guardo o cargó al implementarlo en una clase derivada. (Se hereda de ConfigurationSection). |
|
IsReadOnly | Obtiene un valor que indica si el objeto ConfigurationElement es de sólo lectura. (Se hereda de ConfigurationElement). |
|
ListErrors | Agrega a la lista que se pasa los errores de propiedad no válida que hay en este objeto ConfigurationElement y en todos los subelementos. (Se hereda de ConfigurationElement). |
|
MemberwiseClone | Crea una copia superficial del objeto Object actual. (Se hereda de Object). |
|
OnDeserializeUnrecognizedAttribute | Obtiene un valor que indica si se ha encontrado un atributo desconocido durante la deserialización. (Se hereda de ConfigurationElement). |
|
OnDeserializeUnrecognizedElement | Obtiene un valor que indica si se ha encontrado un elemento desconocido durante la deserialización. (Se hereda de ConfigurationElement). |
|
OnRequiredPropertyNotFound | Se inicia una excepción cuando no se encuentra una propiedad necesaria. (Se hereda de ConfigurationElement). |
|
PostDeserialize | Se llama a este método después de la deserialización. (Se hereda de ConfigurationElement). |
|
PreSerialize | Se llama a este método antes de la serialización. (Se hereda de ConfigurationElement). |
|
Reset | Restablece el estado interno del objeto ConfigurationElement, incluyendo los bloqueos y las colecciones de propiedades. (Se hereda de ConfigurationElement). |
|
ResetModified | Restablece el valor del método IsModified en false al implementarlo en una clase derivada. (Se hereda de ConfigurationSection). |
|
SerializeElement | Escribe el contenido de este elemento de configuración en el archivo de configuración cuando se implementa en una clase derivada. (Se hereda de ConfigurationElement). |
|
SerializeSection | Infraestructura. Crea una cadena XML que contiene una vista separada del objeto ConfigurationSection como una sección única para escribir en un archivo. (Se hereda de ConfigurationSection). |
|
SerializeToXmlElement | Escribe las etiquetas externas de este elemento de configuración en el archivo de configuración cuando se implementa en una clase derivada. (Se hereda de ConfigurationElement). |
|
SetPropertyValue | Establece una propiedad en el valor especificado. (Se hereda de ConfigurationElement). |
|
SetReadOnly | Establece la propiedad IsReadOnly para el objeto ConfigurationElement y todos los subelementos. (Se hereda de ConfigurationElement). |
|
ShouldSerializeElementInTargetVersion | Indica si se debe serializar el elemento especificado cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework. (Se hereda de ConfigurationSection). |
|
ShouldSerializePropertyInTargetVersion | Indica si se debe serializar la propiedad especificada cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework. (Se hereda de ConfigurationSection). |
|
ShouldSerializeSectionInTargetVersion | Indica si se debe serializar la instancia actual de ConfigurationSection cuando la jerarquía de objetos de configuración se serializa para la versión de destino especificada de .NET Framework. (Se hereda de ConfigurationSection). |
|
ToString | Devuelve una cadena que representa el objeto actual. (Se hereda de Object). |
|
Unmerge | Modifica el objeto ConfigurationElement para quitar todos los valores que no se deben guardar. (Se hereda de ConfigurationElement). |
La clase PagesSection proporciona un medio para obtener acceso y modificar mediante programación el contenido de la sección pages del archivo de configuración. Esta sección de configuración admite la configuración global de algunas directivas de controles y páginas de ASP.NET en todas las páginas y controles del ámbito del archivo de configuración. Incluye la directiva @ Page, la directiva @ Import a través de la propiedad de colección Namespaces y la directiva @ Register a través de la propiedad de colección Controls. También proporciona compatibilidad para asignar tipos de etiqueta a otros tipos de etiqueta en tiempo de ejecución, a través de la propiedad de colección TagMapping.
Las directivas especifican la configuración que utilizan los compiladores de control de usuario y de página al procesar archivos de páginas de formularios Web Forms ASP.NET (.aspx) y archivos de controles de usuario (.ascx).
En este ejemplo se muestra cómo especificar de forma declarativa los valores de varios atributos de la sección pages, a la que también se puede obtener acceso como miembro de la clase PagesSection.
En el siguiente ejemplo de archivo de configuración se muestra cómo especificar de forma declarativa los valores de la sección pages.
<system.web>
<pages buffer="true"
enableSessionState="true"
enableViewState="true"
enableViewStateMac="true"
autoEventWireup="true"
validateRequest="true"
asyncTimeout="45"
maintainScrollPositionOnPostBack = "False"
viewStateEncryptionMode = "Auto">
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.ComponentModel" />
<add namespace="System.Configuration" />
<add namespace="System.Web" />
</namespaces>
<controls>
<clear />
<remove tagPrefix="MyTags" />
<!—- Searches all linked assemblies for the namespace -->
<add tagPrefix="MyTags1" namespace=" MyNameSpace "/>
<!-- Uses a specified assembly -->
<add tagPrefix="MyTags2" namespace="MyNameSpace"
assembly="MyAssembly"/>
<!-- Uses the specified source for the user control -->
<add tagprefix="MyTags3" tagname="MyCtrl"
src="MyControl.ascx"/>
</controls>
<tagMapping>
<clear />
<add
tagTypeName=
"System.Web.UI.WebControls.WebParts.WebPartManager"
mappedTagTypeName=
"Microsoft.Sharepoint.WebPartPartManager,
MSPS.Web.dll, Version='2.0.0.0'"
/>
<remove tagTypeName="SomeOtherNS.Class, Assemblyname" />
</tagMapping>
</pages>
</system.web>
En el ejemplo de código siguiente se muestra cómo se utiliza la clase PagesSection.
using System; using System.Collections; using System.Collections.Specialized; using System.Configuration; using System.Web.Configuration; using System.Web.UI; namespace Samples.Aspnet.SystemWebConfiguration { class UsingPagesSection { public static void Main() { try { // Get the Web application configuration. Configuration configuration = WebConfigurationManager.OpenWebConfiguration(""); // Get the section. PagesSection pagesSection = (PagesSection)configuration.GetSection("system.web/pages"); // Get the AutoImportVBNamespace property. Console.WriteLine("AutoImportVBNamespace: '{0}'", pagesSection.Namespaces.AutoImportVBNamespace.ToString()); // Set the AutoImportVBNamespace property. pagesSection.Namespaces.AutoImportVBNamespace = true; // Get all current Namespaces in the collection. for (int i = 0; i < pagesSection.Namespaces.Count; i++) { Console.WriteLine( "Namespaces {0}: '{1}'", i, pagesSection.Namespaces[i].Namespace); } // Create a new NamespaceInfo object. System.Web.Configuration.NamespaceInfo namespaceInfo = new System.Web.Configuration.NamespaceInfo("System"); // Set the Namespace property. namespaceInfo.Namespace = "System.Collections"; // Execute the Add Method. pagesSection.Namespaces.Add(namespaceInfo); // Add a NamespaceInfo object using a constructor. pagesSection.Namespaces.Add( new System.Web.Configuration.NamespaceInfo( "System.Collections.Specialized")); // Execute the RemoveAt method. pagesSection.Namespaces.RemoveAt(0); // Execute the Clear method. pagesSection.Namespaces.Clear(); // Execute the Remove method. pagesSection.Namespaces.Remove("System.Collections"); // Get the current AutoImportVBNamespace property value. Console.WriteLine( "Current AutoImportVBNamespace value: '{0}'", pagesSection.Namespaces.AutoImportVBNamespace); // Set the AutoImportVBNamespace property to false. pagesSection.Namespaces.AutoImportVBNamespace = false; // Get the current PageParserFilterType property value. Console.WriteLine( "Current PageParserFilterType value: '{0}'", pagesSection.PageParserFilterType); // Set the PageParserFilterType property to // "MyNameSpace.AllowOnlySafeControls". pagesSection.PageParserFilterType = "MyNameSpace.AllowOnlySafeControls"; // Get the current Theme property value. Console.WriteLine( "Current Theme value: '{0}'", pagesSection.Theme); // Set the Theme property to "MyCustomTheme". pagesSection.Theme = "MyCustomTheme"; // Get the current EnableViewState property value. Console.WriteLine( "Current EnableViewState value: '{0}'", pagesSection.EnableViewState); // Set the EnableViewState property to false. pagesSection.EnableViewState = false; // Get the current CompilationMode property value. Console.WriteLine( "Current CompilationMode value: '{0}'", pagesSection.CompilationMode); // Set the CompilationMode property to CompilationMode.Always. pagesSection.CompilationMode = CompilationMode.Always; // Get the current ValidateRequest property value. Console.WriteLine( "Current ValidateRequest value: '{0}'", pagesSection.ValidateRequest); // Set the ValidateRequest property to true. pagesSection.ValidateRequest = true; // Get the current EnableViewStateMac property value. Console.WriteLine( "Current EnableViewStateMac value: '{0}'", pagesSection.EnableViewStateMac); // Set the EnableViewStateMac property to true. pagesSection.EnableViewStateMac = true; // Get the current AutoEventWireup property value. Console.WriteLine( "Current AutoEventWireup value: '{0}'", pagesSection.AutoEventWireup); // Set the AutoEventWireup property to false. pagesSection.AutoEventWireup = false; // Get the current MaxPageStateFieldLength property value. Console.WriteLine( "Current MaxPageStateFieldLength value: '{0}'", pagesSection.MaxPageStateFieldLength); // Set the MaxPageStateFieldLength property to 4098. pagesSection.MaxPageStateFieldLength = 4098; // Get the current UserControlBaseType property value. Console.WriteLine( "Current UserControlBaseType value: '{0}'", pagesSection.UserControlBaseType); // Set the UserControlBaseType property to // "MyNameSpace.MyCustomControlBaseType". pagesSection.UserControlBaseType = "MyNameSpace.MyCustomControlBaseType"; // Get all current Controls in the collection. for (int i = 0; i < pagesSection.Controls.Count; i++) { Console.WriteLine("Control {0}:", i); Console.WriteLine(" TagPrefix = '{0}' ", pagesSection.Controls[i].TagPrefix); Console.WriteLine(" TagName = '{0}' ", pagesSection.Controls[i].TagName); Console.WriteLine(" Source = '{0}' ", pagesSection.Controls[i].Source); Console.WriteLine(" Namespace = '{0}' ", pagesSection.Controls[i].Namespace); Console.WriteLine(" Assembly = '{0}' ", pagesSection.Controls[i].Assembly); } // Create a new TagPrefixInfo object. System.Web.Configuration.TagPrefixInfo tagPrefixInfo = new System.Web.Configuration.TagPrefixInfo("MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", "MyControl.ascx"); // Execute the Add Method. pagesSection.Controls.Add(tagPrefixInfo); // Add a TagPrefixInfo object using a constructor. pagesSection.Controls.Add( new System.Web.Configuration.TagPrefixInfo( "MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", "MyControl.ascx")); // Get the current StyleSheetTheme property value. Console.WriteLine( "Current StyleSheetTheme value: '{0}'", pagesSection.StyleSheetTheme); // Set the StyleSheetTheme property. pagesSection.StyleSheetTheme = "MyCustomStyleSheetTheme"; // Get the current EnableSessionState property value. Console.WriteLine( "Current EnableSessionState value: '{0}'", pagesSection.EnableSessionState); // Set the EnableSessionState property to // PagesEnableSessionState.ReadOnly. pagesSection.EnableSessionState = PagesEnableSessionState.ReadOnly; // Get the current MasterPageFile property value. Console.WriteLine( "Current MasterPageFile value: '{0}'", pagesSection.MasterPageFile); // Set the MasterPageFile property to "MyMasterPage.ascx". pagesSection.MasterPageFile = "MyMasterPage.ascx"; // Get the current Buffer property value. Console.WriteLine( "Current Buffer value: '{0}'", pagesSection.Buffer); // Set the Buffer property to true. pagesSection.Buffer = true; // Get all current TagMappings in the collection. for (int i = 0; i < pagesSection.TagMapping.Count; i++) { Console.WriteLine("TagMapping {0}:", i); Console.WriteLine(" TagTypeName = '{0}'", pagesSection.TagMapping[i].TagType); Console.WriteLine(" MappedTagTypeName = '{0}'", pagesSection.TagMapping[i].MappedTagType); } // Add a TagMapInfo object using a constructor. pagesSection.TagMapping.Add( new System.Web.Configuration.TagMapInfo( "MyNameSpace.MyControl", "MyNameSpace.MyOtherControl")); // Get the current PageBaseType property value. Console.WriteLine( "Current PageBaseType value: '{0}'", pagesSection.PageBaseType); // Set the PageBaseType property to // "MyNameSpace.MyCustomPagelBaseType". pagesSection.PageBaseType = "MyNameSpace.MyCustomPagelBaseType"; // Get the current SmartNavigation property value. Console.WriteLine( "Current SmartNavigation value: '{0}'", pagesSection.SmartNavigation); // Set the SmartNavigation property to true. pagesSection.SmartNavigation = true; // Update if not locked. if (!pagesSection.SectionInformation.IsLocked) { configuration.Save(); Console.WriteLine("** Configuration updated."); } else Console.WriteLine("** Could not update, section is locked."); } catch (System.Exception e) { // Unknown error. Console.WriteLine("A unknown exception detected in" + "UsingPagesSection Main."); Console.WriteLine(e); } Console.ReadLine(); } } // UsingPagesSection class end. } // Samples.Aspnet.SystemWebConfiguration namespace end.
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.