Export (0) Print
Expand All

The Effects of the Validation Handler

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

The third method of the business object, GetCustomerDetails, carries a ValidationCallHandler attribute that specifies the length of the String parameter passed to the method. Attempting to execute the method with an input value that is not five characters long results in an error message generated by the Validation Handler, which the ValidationCallHandler attribute adds to the handler pipeline for the GetCustomerDetails method. Figure 1 illustrates the result.

Ff649939.PI-INTRO-CommonScenario7(en-us,PandP.10).gif

Figure 1
The Validation Handler and a directly approved attribute provide parameter validation

Administrators and operators can add the Validation Handler to the pipeline using the configuration system (Web.config), but it is generally better to use attributes. Usually, the developer will know the limitations of a method or algorithm at design time and can apply the appropriate attributes to validate input. However, keep in mind that the .NET Framework does not guarantee the order in which multiple attributes will be retrieved, so attributes should not be used in situations where the order in which the handlers are executed is considered critical.

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.
Show:
© 2014 Microsoft