CustomErrorCollection.Add(CustomError) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Fügt der Auflistung ein CustomError Objekt hinzu.
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)
Parameter
- customError
- CustomError
Das CustomError hinzuzufügende Objekt ist bereits in der Auflistung vorhanden, oder die Auflistung ist schreibgeschützt.
Beispiele
Im folgenden Codebeispiel wird der CustomError Auflistung ein CustomErrorCollection Objekt hinzugefügt.
Weitere Informationen zum Abrufen der Auflistung finden Sie im Codebeispiel im CustomErrorCollection Klassenthema.
// 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
Hinweise
Bevor Sie der Auflistung einen benutzerdefinierten Fehler hinzufügen, müssen Sie ein CustomError Fehlerobjekt erstellen und die Redirect eigenschaften StatusCode initialisieren.