CustomErrorCollection.Set(CustomError) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the specified CustomError to the collection.
public:
void Set(System::Web::Configuration::CustomError ^ customError);
public void Set (System.Web.Configuration.CustomError customError);
member this.Set : System.Web.Configuration.CustomError -> unit
Public Sub Set (customError As CustomError)
Parameters
- customError
- CustomError
The CustomError to add to the collection.
Examples
The following code example shows how to set the specified CustomError object. Refer to the code example in the CustomErrorCollection class topic to learn how to get the collection.
// Using the Set method.
CustomError newCustomError =
new CustomError(404, "customerror404.htm");
// Update the configuration file.
if (!customErrorsSection.SectionInformation.IsLocked)
{
// Add the new custom error to the collection.
customErrorsCollection.Set(newCustomError);
configuration.Save();
}
' Using the Set method.
Dim newCustomError _
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.Set(newCustomError)
configuration.Save()
End If
Remarks
This specified error replaces the current configuration error element.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈