CustomError Classe
Definição
Configura uma seção de CustomError para mapear um código de erro do ASP.NET para uma página personalizada.Configures a CustomError section to map an ASP.NET error code to a custom page. Essa classe não pode ser herdada.This class cannot be inherited.
public ref class CustomError sealed : System::Configuration::ConfigurationElement
public sealed class CustomError : System.Configuration.ConfigurationElement
type CustomError = class
inherit ConfigurationElement
Public NotInheritable Class CustomError
Inherits ConfigurationElement
- Herança
Exemplos
Este exemplo demonstra como especificar valores de forma declarativa para vários atributos da customErrors seção, que também podem ser acessados como membros da CustomError classe.This example demonstrates how to specify values declaratively for several attributes of the customErrors section, which can also be accessed as members of the CustomError class.
O exemplo de arquivo de configuração a seguir mostra como especificar valores declarativamente para a customErrors seção.The following configuration file example shows how to specify values declaratively for the customErrors section.
<customErrors mode="RemoteOnly"
defaultRedirect="customerror.htm">
<error statusCode="404" redirect="customerror404.htm"/>
</customErrors>
O exemplo de código a seguir demonstra como usar a CustomError classe.The following code example demonstrates how to use the CustomError class.
// Get the Web application configuration.
Configuration configuration =
WebConfigurationManager.OpenWebConfiguration(
"/aspnetTest");
// Get the section.
CustomErrorsSection customErrors =
(CustomErrorsSection)configuration.GetSection(
"system.web/customErrors");
// Get the collection.
CustomErrorCollection customErrorsCollection =
customErrors.Errors;
' Get the Web application configuration.
Dim configuration _
As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration( _
"/aspnetTest")
' Get the section.
Dim customErrors As CustomErrorsSection = _
CType(configuration.GetSection( _
"system.web/customErrors"), CustomErrorsSection)
' Get the collection.
Dim customErrorsCollection _
As CustomErrorCollection = _
customErrors.Errors
Comentários
A classe CustomError oferece uma maneira de acessar e modificar programaticamente a seção error de um arquivo de configuração.The CustomError class provides a way to programmatically access and modify the error section of a configuration file. Esse tipo é parte de um grupo que inclui o CustomErrorCollection , o CustomErrorsMode e o CustomErrorsSection .This type is part of a group that includes the CustomErrorCollection, CustomErrorsMode, and CustomErrorsSection.
Observação
Quando você define um erro personalizado, o ASP.NET atribui a ele o erro padrão normalmente emitido pelo serviço subjacente, como o IIS.When you define a custom error, ASP.NET assigns to it the standard error normally issued by the underlying service, such as IIS. Por exemplo, se você definir um erro personalizado para o código de status 404, o ASP.NET o emitirá sempre que você se referir a uma página. aspx inexistente.For instance, if you define a custom error for the status code 404, ASP.NET will issue it anytime you refer to a non-existing .aspx page. Os erros personalizados são emitidos apenas para os elementos tratados pelo ASP.NET.The custom errors are only issued for those elements handled by ASP.NET. Por exemplo, se você se referir a uma página. htm não existente, o IIS emitirá o erro 404 padrão.For instance, if you refer to a non-existing .htm page, IIS issues the standard 404 error.
Construtores
| CustomError(Int32, String) |
Inicializa uma nova instância da classe CustomError.Initializes a new instance of the CustomError class. |
Propriedades
| CurrentConfiguration |
Obtém uma referência para a instância Configuration de nível superior que representa a hierarquia de configuração à qual a instância atual ConfigurationElement pertence.Gets a reference to the top-level Configuration instance that represents the configuration hierarchy that the current ConfigurationElement instance belongs to. (Herdado de ConfigurationElement) |
| ElementInformation |
Obtém um objeto ElementInformation que contém as informações não personalizáveis e a funcionalidade do objeto ConfigurationElement.Gets an ElementInformation object that contains the non-customizable information and functionality of the ConfigurationElement object. (Herdado de ConfigurationElement) |
| ElementProperty |
Obtém o objeto ConfigurationElementProperty que representa o próprio objeto ConfigurationElement.Gets the ConfigurationElementProperty object that represents the ConfigurationElement object itself. (Herdado de ConfigurationElement) |
| EvaluationContext |
Obtém o objeto ContextInformation para o objeto ConfigurationElement.Gets the ContextInformation object for the ConfigurationElement object. (Herdado de ConfigurationElement) |
| HasContext |
Obtém um valor que indica se a propriedade CurrentConfiguration é |
| Item[ConfigurationProperty] |
Obtém ou define uma propriedade ou um atributo desse elemento de configuração.Gets or sets a property or attribute of this configuration element. (Herdado de ConfigurationElement) |
| Item[String] |
Obtém ou define uma propriedade, atributo ou elemento filho desse elemento de configuração.Gets or sets a property, attribute, or child element of this configuration element. (Herdado de ConfigurationElement) |
| LockAllAttributesExcept |
Obtém a coleção de atributos bloqueados.Gets the collection of locked attributes. (Herdado de ConfigurationElement) |
| LockAllElementsExcept |
Obtém a coleção de elementos bloqueados.Gets the collection of locked elements. (Herdado de ConfigurationElement) |
| LockAttributes |
Obtém a coleção de atributos bloqueados.Gets the collection of locked attributes. (Herdado de ConfigurationElement) |
| LockElements |
Obtém a coleção de elementos bloqueados.Gets the collection of locked elements. (Herdado de ConfigurationElement) |
| LockItem |
Obtém ou define um valor que indica se o elemento está bloqueado.Gets or sets a value indicating whether the element is locked. (Herdado de ConfigurationElement) |
| Properties |
Obtém a coleção de propriedades.Gets the collection of properties. (Herdado de ConfigurationElement) |
| Redirect |
Obtém ou define a URL de redirecionamento.Gets or sets the redirection URL. |
| StatusCode |
Obtém ou define o código de status de erro HTTP.Gets or sets the HTTP error status code. |
Métodos
| DeserializeElement(XmlReader, Boolean) |
Lê o XML do arquivo de configuração.Reads XML from the configuration file. (Herdado de ConfigurationElement) |
| Equals(Object) |
Compara erros CustomError.Compares CustomError errors. |
| GetHashCode() |
Obtém o código hash do objeto CustomError.Gets the CustomError object hash code. |
| GetTransformedAssemblyString(String) |
Retorna a versão transformada do nome do assembly especificado.Returns the transformed version of the specified assembly name. (Herdado de ConfigurationElement) |
| GetTransformedTypeString(String) |
Retorna a versão transformada do nome do tipo especificado.Returns the transformed version of the specified type name. (Herdado de ConfigurationElement) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| Init() |
Define o objeto ConfigurationElement para seu estado inicial.Sets the ConfigurationElement object to its initial state. (Herdado de ConfigurationElement) |
| InitializeDefault() |
Usado para inicializar um conjunto padrão de valores para o objeto ConfigurationElement.Used to initialize a default set of values for the ConfigurationElement object. (Herdado de ConfigurationElement) |
| IsModified() |
Indica se este elemento de configuração foi modificado desde a última vez em que foi salvo ou carregado quando implementado em uma classe derivada.Indicates whether this configuration element has been modified since it was last saved or loaded, when implemented in a derived class. (Herdado de ConfigurationElement) |
| IsReadOnly() |
Obtém um valor que indica se o objeto ConfigurationElement é somente leitura.Gets a value indicating whether the ConfigurationElement object is read-only. (Herdado de ConfigurationElement) |
| ListErrors(IList) |
Adiciona os erros de propriedade inválida deste objeto ConfigurationElement e de todos os subelementos à lista passada.Adds the invalid-property errors in this ConfigurationElement object, and in all subelements, to the passed list. (Herdado de ConfigurationElement) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
Obtém um valor que indica se um atributo desconhecido é encontrado durante a desserialização.Gets a value indicating whether an unknown attribute is encountered during deserialization. (Herdado de ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
Obtém um valor que indica se um elemento desconhecido é encontrado durante a desserialização.Gets a value indicating whether an unknown element is encountered during deserialization. (Herdado de ConfigurationElement) |
| OnRequiredPropertyNotFound(String) |
Gera uma exceção quando uma propriedade necessária não é encontrada.Throws an exception when a required property is not found. (Herdado de ConfigurationElement) |
| PostDeserialize() |
Chamado depois da desserialização.Called after deserialization. (Herdado de ConfigurationElement) |
| PreSerialize(XmlWriter) |
Chamado antes da serialização.Called before serialization. (Herdado de ConfigurationElement) |
| Reset(ConfigurationElement) |
Redefine o estado interno do objeto ConfigurationElement, incluindo os bloqueios e as coleções de propriedades.Resets the internal state of the ConfigurationElement object, including the locks and the properties collections. (Herdado de ConfigurationElement) |
| ResetModified() |
Redefine o valor do método IsModified() para |
| SerializeElement(XmlWriter, Boolean) |
Grava o conteúdo desse elemento de configuração no arquivo de configuração quando implementado em uma classe derivada.Writes the contents of this configuration element to the configuration file when implemented in a derived class. (Herdado de ConfigurationElement) |
| SerializeToXmlElement(XmlWriter, String) |
Grava as marcas externas desse elemento de configuração no arquivo de configuração quando implementado em uma classe derivada.Writes the outer tags of this configuration element to the configuration file when implemented in a derived class. (Herdado de ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
Define uma propriedade para o valor especificado.Sets a property to the specified value. (Herdado de ConfigurationElement) |
| SetReadOnly() |
Define a propriedade IsReadOnly() para o objeto ConfigurationElement e para todos os subelementos.Sets the IsReadOnly() property for the ConfigurationElement object and all subelements. (Herdado de ConfigurationElement) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
Modifica o objeto ConfigurationElement para remover todos os valores que não devem ser salvos.Modifies the ConfigurationElement object to remove all values that should not be saved. (Herdado de ConfigurationElement) |