CustomErrorCollection.Add(CustomError) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
CustomError Menambahkan objek ke koleksi.
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
Objek CustomError yang ditambahkan sudah ada dalam koleksi atau koleksi hanya dibaca.
Contoh
Contoh kode berikut menambahkan CustomError objek ke CustomErrorCollection koleksi.
Lihat contoh kode dalam CustomErrorCollection topik kelas untuk mempelajari cara mendapatkan koleksi.
// 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
Keterangan
Sebelum menambahkan kesalahan kustom ke koleksi, Anda harus membuat CustomError objek kesalahan dan menginisialisasi Redirect properti dan StatusCode .