As developers, we get to influence some of the ways views—and, in particular, Razor views—work. Normally, this is done through configuration, through AddViewOptions and AddRazorOptions extension methods, which are commonly called in sequence to AddMvc, in the ConfigureServices method, as illustrated in the following code snippet:
services
.AddMvc()
.AddViewOptions(options =>
{
//global view options
})
.AddRazorOptions(options =>
{
//razor-specific options
});
Through AddViewOptions, we can configure the following properties of the MvcViewOptions class:
- ClientModelValidatorProviders (IList<IClientModelValidatorProvider>): A collection of client-model validator providers, to be used when the model is to be validated on the client side; this will be discussed in Chapter 11, Security, but by default, it includes DefaultClientModelValidatorProvider, DataAnnotationsClientModelValidatorProvider...