CustomErrorCollection.Add(CustomError) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Adiciona um CustomError objeto à coleção.
public:
void Add(System::Web::Configuration::CustomError ^ customError);
public void Add(System.Web.Configuration.CustomError customError);
member this.Add : System.Web.Configuration.CustomError -> unit
Public Sub Add (customError As CustomError)
Parâmetros
- customError
- CustomError
O CustomError objeto a adicionar já existe na coleção ou a coleção é apenas leitura.
Exemplos
O exemplo de código seguinte adiciona um CustomError objeto à CustomErrorCollection coleção.
Consulta o exemplo do código no CustomErrorCollection tópico da aula para saberes como obter a coleção.
// Using the Add method.
CustomError newCustomError2 =
new CustomError(404, "customerror404.htm");
// Update the configuration file.
if (!customErrorsSection.SectionInformation.IsLocked)
{
// Add the new custom error to the collection.
customErrorsCollection.Add(newCustomError2);
configuration.Save();
}
' Using the Add method.
Dim newCustomError2 _
As New CustomError(404, "customerror404.htm")
' Update the configuration file.
If Not customErrorsSection.SectionInformation.IsLocked Then
' Add the new custom error to the collection.
customErrorsCollection.Add(newCustomError2)
configuration.Save()
End If
Observações
Antes de adicionar um erro personalizado à coleção, deve criar um CustomError objeto de erro e inicializar as Redirect propriedades e.StatusCode