From 4f28e4f4437d6bac2cd91496c562694a4db684bf Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 23 Oct 2020 17:11:07 -0400 Subject: [PATCH] Referred to ModelState.IsValid as a property (#20291) In the "Processing the POST Request" section we have a paragraph telling us that "The `ModelState.IsValid` method verifies...", I thought it must be an error because as we can see in the documentation ModelState.IsValid is not a method but a property https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelbinding.modelstatedictionary.isvalid?view=aspnetcore-3.1#Microsoft_AspNetCore_Mvc_ModelBinding_ModelStateDictionary_IsValid --- aspnetcore/tutorials/first-mvc-app/controller-methods-views.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/tutorials/first-mvc-app/controller-methods-views.md b/aspnetcore/tutorials/first-mvc-app/controller-methods-views.md index f28ddf0b24..4da3f3e3d0 100644 --- a/aspnetcore/tutorials/first-mvc-app/controller-methods-views.md +++ b/aspnetcore/tutorials/first-mvc-app/controller-methods-views.md @@ -134,7 +134,7 @@ The following listing shows the `[HttpPost]` version of the `Edit` action method The `[ValidateAntiForgeryToken]` attribute validates the hidden [XSRF](xref:security/anti-request-forgery) token generated by the anti-forgery token generator in the [Form Tag Helper](xref:mvc/views/working-with-forms) -The [model binding](xref:mvc/models/model-binding) system takes the posted form values and creates a `Movie` object that's passed as the `movie` parameter. The `ModelState.IsValid` method verifies that the data submitted in the form can be used to modify (edit or update) a `Movie` object. If the data is valid, it's saved. The updated (edited) movie data is saved to the database by calling the `SaveChangesAsync` method of database context. After saving the data, the code redirects the user to the `Index` action method of the `MoviesController` class, which displays the movie collection, including the changes just made. +The [model binding](xref:mvc/models/model-binding) system takes the posted form values and creates a `Movie` object that's passed as the `movie` parameter. The `ModelState.IsValid` property verifies that the data submitted in the form can be used to modify (edit or update) a `Movie` object. If the data is valid, it's saved. The updated (edited) movie data is saved to the database by calling the `SaveChangesAsync` method of database context. After saving the data, the code redirects the user to the `Index` action method of the `MoviesController` class, which displays the movie collection, including the changes just made. Before the form is posted to the server, client-side validation checks any validation rules on the fields. If there are any validation errors, an error message is displayed and the form isn't posted. If JavaScript is disabled, you won't have client-side validation but the server will detect the posted values that are not valid, and the form values will be redisplayed with error messages. Later in the tutorial we examine [Model Validation](xref:mvc/models/validation) in more detail. The [Validation Tag Helper](xref:mvc/views/working-with-forms) in the *Views/Movies/Edit.cshtml* view template takes care of displaying appropriate error messages.