Restore missing Model State code snippet (#10199)

pull/10206/head
Scott Addie 2019-01-04 10:28:27 -06:00 committed by GitHub
parent cb3b33dd2f
commit 8caa93e2fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -4,7 +4,7 @@ author: tdykstra
description: Learn about model validation in ASP.NET Core MVC.
ms.author: riande
ms.custom: mvc
ms.date: 11/06/2018
ms.date: 01/04/2019
uid: mvc/models/validation
---
# Model validation in ASP.NET Core MVC
@ -78,7 +78,7 @@ Model state represents validation errors in submitted HTML form values.
MVC will continue validating fields until it reaches the maximum number of errors (200 by default). You can configure this number with the following code in `Startup.ConfigureServices`:
[!code-csharp[](validation/sample/Startup.cs?range=27)]
[!code-csharp[](validation/sample/Startup.cs?name=snippet_MaxModelValidationErrors)]
## Handle Model State errors

View File

@ -11,8 +11,10 @@ namespace MVCMovie
{
services.AddSingleton(new MVCMovieContext());
services.AddSingleton<IUserRepository>(new UserRepository());
#region snippet_MaxModelValidationErrors
services.AddMvc(options => options.MaxModelValidationErrors = 50)
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
#endregion
}
public void Configure(IApplicationBuilder app)