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