From 8caa93e2fb0bdcd14cea9776b4743ae1685b2584 Mon Sep 17 00:00:00 2001 From: Scott Addie <10702007+scottaddie@users.noreply.github.com> Date: Fri, 4 Jan 2019 10:28:27 -0600 Subject: [PATCH] Restore missing Model State code snippet (#10199) --- aspnetcore/mvc/models/validation.md | 4 ++-- aspnetcore/mvc/models/validation/sample/Startup.cs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/aspnetcore/mvc/models/validation.md b/aspnetcore/mvc/models/validation.md index c83be2aaac..33483f6b5a 100644 --- a/aspnetcore/mvc/models/validation.md +++ b/aspnetcore/mvc/models/validation.md @@ -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 diff --git a/aspnetcore/mvc/models/validation/sample/Startup.cs b/aspnetcore/mvc/models/validation/sample/Startup.cs index 6f73b17be1..f25ba0a890 100644 --- a/aspnetcore/mvc/models/validation/sample/Startup.cs +++ b/aspnetcore/mvc/models/validation/sample/Startup.cs @@ -11,8 +11,10 @@ namespace MVCMovie { services.AddSingleton(new MVCMovieContext()); services.AddSingleton(new UserRepository()); + #region snippet_MaxModelValidationErrors services.AddMvc(options => options.MaxModelValidationErrors = 50) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + #endregion } public void Configure(IApplicationBuilder app)