219 references to AddModelError
Identity.ExternalClaims (10)
Pages\Account\ExternalLogin.cshtml.cs (1)
140ModelState.AddModelError(string.Empty, error.Description);
Pages\Account\Login.cshtml.cs (2)
57ModelState.AddModelError(string.Empty, ErrorMessage); 93ModelState.AddModelError(string.Empty, "Invalid login attempt.");
Pages\Account\LoginWith2fa.cshtml.cs (1)
93ModelState.AddModelError(string.Empty, "Invalid authenticator code.");
Pages\Account\LoginWithRecoveryCode.cshtml.cs (1)
86ModelState.AddModelError(string.Empty, "Invalid recovery code entered.");
Pages\Account\Manage\ChangePassword.cshtml.cs (1)
93ModelState.AddModelError(string.Empty, error.Description);
Pages\Account\Manage\EnableAuthenticator.cshtml.cs (1)
95ModelState.AddModelError("Input.Code", "Verification code is invalid.");
Pages\Account\Manage\SetPassword.cshtml.cs (1)
85ModelState.AddModelError(string.Empty, error.Description);
Pages\Account\Register.cshtml.cs (1)
86ModelState.AddModelError(string.Empty, error.Description);
Pages\Account\ResetPassword.cshtml.cs (1)
85ModelState.AddModelError(string.Empty, error.Description);
IdentitySample.DefaultUI (1)
Areas\Identity\Pages\Account\Register.cshtml.cs (1)
116ModelState.AddModelError(string.Empty, error.Description);
IdentitySample.Mvc (8)
Controllers\AccountController.cs (6)
77ModelState.AddModelError(string.Empty, "Invalid login attempt."); 159ModelState.AddModelError(string.Empty, $"Error from external provider: {remoteError}"); 444ModelState.AddModelError(string.Empty, "Invalid code."); 491ModelState.AddModelError(string.Empty, "Invalid code."); 530ModelState.AddModelError(string.Empty, "Invalid code."); 541ModelState.AddModelError(string.Empty, error.Description);
Controllers\ManageController.cs (2)
201ModelState.AddModelError(string.Empty, "Failed to verify phone number"); 355ModelState.AddModelError(string.Empty, error.Description);
Microsoft.AspNetCore.Identity.UI (26)
Areas\Identity\Pages\V4\Account\ExternalLogin.cshtml.cs (1)
222ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V4\Account\Login.cshtml.cs (2)
107ModelState.AddModelError(string.Empty, ErrorMessage); 147ModelState.AddModelError(string.Empty, "Invalid login attempt.");
Areas\Identity\Pages\V4\Account\LoginWith2fa.cshtml.cs (1)
143ModelState.AddModelError(string.Empty, "Invalid authenticator code.");
Areas\Identity\Pages\V4\Account\LoginWithRecoveryCode.cshtml.cs (1)
126ModelState.AddModelError(string.Empty, "Invalid recovery code entered.");
Areas\Identity\Pages\V4\Account\Manage\ChangePassword.cshtml.cs (1)
131ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V4\Account\Manage\DeletePersonalData.cshtml.cs (1)
100ModelState.AddModelError(string.Empty, "Incorrect password.");
Areas\Identity\Pages\V4\Account\Manage\EnableAuthenticator.cshtml.cs (1)
138ModelState.AddModelError("Input.Code", "Verification code is invalid.");
Areas\Identity\Pages\V4\Account\Manage\SetPassword.cshtml.cs (1)
119ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V4\Account\Register.cshtml.cs (1)
162ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V4\Account\ResendEmailConfirmation.cshtml.cs (2)
82ModelState.AddModelError(string.Empty, "Verification email sent. Please check your email."); 96ModelState.AddModelError(string.Empty, "Verification email sent. Please check your email.");
Areas\Identity\Pages\V4\Account\ResetPassword.cshtml.cs (1)
128ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V5\Account\ExternalLogin.cshtml.cs (1)
222ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V5\Account\Login.cshtml.cs (2)
107ModelState.AddModelError(string.Empty, ErrorMessage); 147ModelState.AddModelError(string.Empty, "Invalid login attempt.");
Areas\Identity\Pages\V5\Account\LoginWith2fa.cshtml.cs (1)
143ModelState.AddModelError(string.Empty, "Invalid authenticator code.");
Areas\Identity\Pages\V5\Account\LoginWithRecoveryCode.cshtml.cs (1)
126ModelState.AddModelError(string.Empty, "Invalid recovery code entered.");
Areas\Identity\Pages\V5\Account\Manage\ChangePassword.cshtml.cs (1)
131ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V5\Account\Manage\DeletePersonalData.cshtml.cs (1)
100ModelState.AddModelError(string.Empty, "Incorrect password.");
Areas\Identity\Pages\V5\Account\Manage\EnableAuthenticator.cshtml.cs (1)
138ModelState.AddModelError("Input.Code", "Verification code is invalid.");
Areas\Identity\Pages\V5\Account\Manage\SetPassword.cshtml.cs (1)
119ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V5\Account\Register.cshtml.cs (1)
162ModelState.AddModelError(string.Empty, error.Description);
Areas\Identity\Pages\V5\Account\ResendEmailConfirmation.cshtml.cs (2)
82ModelState.AddModelError(string.Empty, "Verification email sent. Please check your email."); 96ModelState.AddModelError(string.Empty, "Verification email sent. Please check your email.");
Areas\Identity\Pages\V5\Account\ResetPassword.cshtml.cs (1)
128ModelState.AddModelError(string.Empty, error.Description);
Microsoft.AspNetCore.Mvc.Abstractions.Test (51)
ModelBinding\ModelStateDictionaryTest.cs (51)
19dictionary.AddModelError("foo.bar", "some error"); 35dictionary.AddModelError(key, "some error"); 72modelStateDictionary.AddModelError("foo.bar[10].baz", "error-message"); 112dictionary.AddModelError("a", "a-error"); 113dictionary.AddModelError("b", "b-error"); 114dictionary.AddModelError("c", "c-error"); 190source.AddModelError("key", "some error"); 249source.AddModelError("key", "some-error"); 309dictionary.AddModelError("some key", "some error"); 324dictionary.AddModelError("some key", "some error"); 375dictionary.AddModelError("foo.bar", "error text"); 392dictionary.AddModelError(key, "error text"); 425dictionary.AddModelError(key, "error text"); 456dictionary.AddModelError("bar", "some error"); 537dictionary.AddModelError("baz", "some error"); 554dictionary1.AddModelError("foo", "value1-Error1"); 555dictionary1.AddModelError("foo", "value1-Error2"); 559dictionary2.AddModelError("bar", "value2-Error1"); 585dictionary1.AddModelError(key, "value1-Error1"); 586dictionary1.AddModelError(key, "value1-Error2"); 591dictionary2.AddModelError(key, "value2-Error1"); 648dictionary.AddModelError("some key", "some error"); 685dictionary.AddModelError("user.Age", "Age is not a valid int"); 704dictionary.AddModelError("user.Age", "Age is not a valid int"); 723dictionary.AddModelError("[0].product.Name", "Name is invalid"); 760dictionary.AddModelError("key1", "error1"); 763dictionary.AddModelError("key4", "error4"); 764dictionary.AddModelError("key5", "error5"); 862dictionary.AddModelError("key2", "error2"); 863dictionary.AddModelError("key3", "error3"); 921dictionary.AddModelError("key1", "error1"); 925copy.AddModelError("key2", "error2"); 948dictionary.AddModelError("key" + i, "error"); 1286dictionary.AddModelError("Property2", "Property2 invalid."); 1287dictionary.AddModelError("Property3", "Property invalid."); 1312dictionary.AddModelError("Product.Detail1", "Product Detail1 invalid."); 1313dictionary.AddModelError("Product.Detail2[0]", "Product Detail2[0] invalid."); 1314dictionary.AddModelError("Product.Detail2[1]", "Product Detail2[1] invalid."); 1317dictionary.AddModelError("ProductName", "ProductName invalid."); 1345dictionary.AddModelError("Product.Detail1", "Product Detail1 invalid."); 1346dictionary.AddModelError("Product.Detail1.Name", "Product Detail1 Name invalid."); 1369dictionary.AddModelError("Property2", "Property2 invalid."); 1370dictionary.AddModelError("Property3", "Property invalid."); 1404dictionary.AddModelError("Property2", "Property invalid."); 1405dictionary.AddModelError("Property2[Property3]", "Property2[Property3] invalid."); 1495dictionary.AddModelError("Property1.Property2", "Property2 invalid."); 1496dictionary.AddModelError("Property2", "Property invalid."); 1497dictionary.AddModelError("Property2[Property3]", "Property2[Property3] invalid."); 1528dictionary.AddModelError("Property2", "Property invalid."); 1529dictionary.AddModelError("Property2[Property3]", "Property2[Property3] invalid."); 1629dictionary.AddModelError(key, "some error");
Microsoft.AspNetCore.Mvc.Core (2)
ModelBinding\Binders\BodyModelBinder.cs (1)
180bindingContext.ModelState.AddModelError(modelBindingKey, message);
ModelBinding\Binders\DictionaryModelBinder.cs (1)
174bindingContext.ModelState.AddModelError(bindingContext.ModelName, ex.Message);
Microsoft.AspNetCore.Mvc.Core.Test (42)
ControllerBaseTest.cs (1)
2342context.ModelState.AddModelError("key1", "error1");
Formatters\JsonInputFormatterTestBase.cs (2)
425formatterContext.ModelState.AddModelError("key1", "error1"); 426formatterContext.ModelState.AddModelError("key2", "error2");
Infrastructure\ModelStateInvalidFilterTest.cs (1)
63context.ModelState.AddModelError("some-key", "some-error");
Infrastructure\ProblemDetailsFactoryTest.cs (3)
85modelState.AddModelError("some-key", "some-value"); 115modelState.AddModelError("some-key", "some-value"); 147modelState.AddModelError("some-key", "some-value");
ModelBinding\ModelBindingHelperTest.cs (17)
644dictionary.AddModelError("Name", "MyProperty invalid."); 645dictionary.AddModelError("Id", "Id invalid."); 646dictionary.AddModelError("Id", "Id is required."); 648dictionary.AddModelError("Unrelated", "Unrelated is required."); 676dictionary.AddModelError(string.Empty, "MyProperty invalid."); 677dictionary.AddModelError("Unrelated", "Unrelated is required."); 700dictionary.AddModelError("[0].Name", "Name invalid."); 701dictionary.AddModelError("[0].Id", "Id invalid."); 702dictionary.AddModelError("[0].Id", "Id required."); 707dictionary.AddModelError("[1].Category", "Category invalid."); 708dictionary.AddModelError("Unrelated", "Unrelated is required."); 745dictionary.AddModelError("product.Name", "Name invalid."); 746dictionary.AddModelError("product.Id", "Id invalid."); 747dictionary.AddModelError("product.Id", "Id required."); 750dictionary.AddModelError("product.Order[0].Name", "Order name invalid."); 751dictionary.AddModelError("product.Order[0].Address.Street", "Street invalid."); 753dictionary.AddModelError("product.Order[0]", "Order invalid.");
ModelBinding\ParameterBinderTest.cs (5)
276context.ModelState.AddModelError(prefix, "Test validation message"); 538modelState.AddModelError("id", "This is not valid."); 597modelState.AddModelError("id", "This is not valid."); 600modelState.AddModelError(string.Empty, "This is also not valid."); 669modelState.AddModelError("id", "This is not valid.");
ModelBinding\UnsupportedContentTypeFilterTest.cs (1)
61context.ModelState.AddModelError("person.body", "Some error");
ModelBinding\Validation\DefaultObjectValidatorTests.cs (4)
87modelState.AddModelError("other.Model", "error"); 729modelState.AddModelError("key1", "error1"); 1227modelState.AddModelError(key: "one", errorMessage: "1"); 1228modelState.AddModelError(key: "two", errorMessage: "2");
SerializableErrorTests.cs (5)
15modelState.AddModelError("key1", "Test Error 1"); 16modelState.AddModelError("key1", "Test Error 2"); 17modelState.AddModelError("key2", "Test Error 3"); 34modelState.AddModelError("key1", "x"); 49modelState.AddModelError("key1", "");
ValidationProblemDetailsTest.cs (3)
26modelStateDictionary.AddModelError("key1", "error1"); 28modelStateDictionary.AddModelError("key3", "error2"); 29modelStateDictionary.AddModelError("key3", "error3");
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (5)
SerializableErrorWrapperTests.cs (5)
100modelState.AddModelError(string.Empty, "Test error 0"); 101modelState.AddModelError("key1", "Test Error 1"); 102modelState.AddModelError("key1", "Test Error 2"); 103modelState.AddModelError("key2", "Test Error 3"); 104modelState.AddModelError("list[3].key3", "Test Error 4");
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (2)
src\Mvc\Mvc.Core\test\Formatters\JsonInputFormatterTestBase.cs (2)
425formatterContext.ModelState.AddModelError("key1", "error1"); 426formatterContext.ModelState.AddModelError("key2", "error2");
Microsoft.AspNetCore.Mvc.RazorPages.Test (1)
PageLoggerExtensionsTest.cs (1)
138context.ModelState.AddModelError("foo", "bar");
Microsoft.AspNetCore.Mvc.TagHelpers.Test (5)
ValidationSummaryTagHelperTest.cs (5)
146invalidModelState.AddModelError($"{nameof(Model.Strings)}[1]", "This value is invalid."); 248modelState.AddModelError(string.Empty, expectedError); 318modelState.AddModelError(key: $"{nameof(Model.Strings)}[0]", errorMessage: expectedError0); 319modelState.AddModelError(key: $"{nameof(Model.Strings)}[2]", errorMessage: expectedError2); 632viewContext.ModelState.AddModelError(key: nameof(FormMetadata.ID), errorMessage: expectedError);
Microsoft.AspNetCore.Mvc.ViewFeatures (1)
ModelStateDictionaryExtensions.cs (1)
34modelState.AddModelError(GetExpressionText(expression), errorMessage);
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (60)
ControllerUnitTestabilityTests.cs (1)
706controller.ModelState.AddModelError("some-key", "some-error");
Rendering\HtmlHelperHiddenTest.cs (2)
972viewData.ModelState.AddModelError("Property1", "error 1"); 973viewData.ModelState.AddModelError("Property1", "error 2");
Rendering\HtmlHelperPasswordTest.cs (2)
466viewData.ModelState.AddModelError("Property1", "error 1"); 467viewData.ModelState.AddModelError("Property1", "error 2");
Rendering\HtmlHelperValidationSummaryTest.cs (55)
209html.ViewData.ModelState.AddModelError(string.Empty, "This is my validation message"); 235html.ViewData.ModelState.AddModelError("this.is.my.prefix", "This is my validation message"); 260html.ViewData.ModelState.AddModelError("Property1", "This is my validation message"); 314html.ViewData.ModelState.AddModelError("Property2", "New error for Property2."); 348html.ViewData.ModelState.AddModelError("non-existent-property1", "non-existent-error1"); 349html.ViewData.ModelState.AddModelError("non.existent.property2", "non-existent-error2"); 350html.ViewData.ModelState.AddModelError("non.existent[0].property3", "non-existent-error3"); 376html.ViewData.ModelState.AddModelError("Property1", "Property1 error"); 377html.ViewData.ModelState.AddModelError("Property2[0].OrderedProperty1", "Property2[0].OrderedProperty1 error"); 378html.ViewData.ModelState.AddModelError("Property2[10].Property2", "Property2[10].Property2 error"); 379html.ViewData.ModelState.AddModelError("Property2[2].Property3", "Property2[2].Property3 error"); 380html.ViewData.ModelState.AddModelError("Property2[0].Property1", "Property2[0].Property1 error"); 406html.ViewData.ModelState.AddModelError("[0].OrderedProperty2", "[0].OrderedProperty2 error"); 407html.ViewData.ModelState.AddModelError("[0].Property1", "[0].Property1 error"); 408html.ViewData.ModelState.AddModelError("[0].OrderedProperty1", "[0].OrderedProperty1 error"); 409html.ViewData.ModelState.AddModelError("[2].Property3", "[2].Property3 error"); 410html.ViewData.ModelState.AddModelError("[2].OrderedProperty3", "[2].OrderedProperty3 error"); 438html.ViewData.ModelState.AddModelError("[0].OrderedProperty2", "[0].OrderedProperty2 error"); 439html.ViewData.ModelState.AddModelError("[0].Property1", "[0].Property1 error"); 440html.ViewData.ModelState.AddModelError("[0].OrderedProperty1", "[0].OrderedProperty1 error"); 441html.ViewData.ModelState.AddModelError("[2].Property3", "[2].Property3 error"); 442html.ViewData.ModelState.AddModelError("[2].OrderedProperty3", "[2].OrderedProperty3 error"); 443html.ViewData.ModelState.AddModelError("OrderedProperty1", "OrderedProperty1 error"); 444html.ViewData.ModelState.AddModelError("OrderedProperty2", "OrderedProperty2 error"); 495helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 513helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 527helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 546helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 565helper.ViewData.ModelState.AddModelError(string.Empty, "Error for root"); 566helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 585helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 604helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 623helper.ViewData.ModelState.AddModelError(string.Empty, "Error for root"); 624helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 643helper.ViewData.ModelState.AddModelError(string.Empty, "Error for root"); 644helper.ViewData.ModelState.AddModelError("Property1", "Error for Property1"); 664modelState.AddModelError("Property3.Property2", "This is an error for Property3.Property2."); 665modelState.AddModelError("Property3.OrderedProperty3", "This is an error for Property3.OrderedProperty3."); 666modelState.AddModelError("Property3.OrderedProperty2", "This is an error for Property3.OrderedProperty2."); 672modelState.AddModelError("Property3", "This is an error for Property3."); 676modelState.AddModelError("Property2", "This is an error for Property2."); 677modelState.AddModelError("Property2", "This is another error for Property2."); 681modelState.AddModelError(string.Empty, "This is an error for the model root."); 682modelState.AddModelError(string.Empty, "This is another error for the model root."); 691modelState.AddModelError("Property3", "This is an error for Property3."); 694modelState.AddModelError("Property2", "This is an error for Property2."); 695modelState.AddModelError("Property2", "This is another error for Property2."); 697modelState.AddModelError("OrderedProperty3", "This is an error for OrderedProperty3."); 699modelState.AddModelError("OrderedProperty2", "This is an error for OrderedProperty2."); 700modelState.AddModelError("OrderedProperty2", "This is another error for OrderedProperty2."); 702modelState.AddModelError("LastProperty", "This is an error for LastProperty."); 704modelState.AddModelError("Property1", "This is an error for Property1."); 705modelState.AddModelError("Property1", "This is another error for Property1."); 707modelState.AddModelError("OrderedProperty1", "This is an error for OrderedProperty1."); 708modelState.AddModelError("OrderedProperty2", "This is yet-another error for OrderedProperty2.");
RazorWebSite (4)
Controllers\HtmlHelperOptionsController.cs (4)
25ModelState.AddModelError(string.Empty, "A model error occurred."); 26ModelState.AddModelError("Error", "An error occurred."); 45ModelState.AddModelError(string.Empty, "A model error occurred."); 46ModelState.AddModelError("Error", "An error occurred.");
XmlFormattersWebSite (1)
Controllers\SerializableErrorController.cs (1)
25ModelState.AddModelError("key1", "key1-error");