No error for incorrect password on protected/Restricted Public Access Page?

I’m using the standard UmbLoginController login code for a protected page, as pulled from this step-by-step. Everything works, but the errors that are supposed to show for an incorrect password, locked account, etc. don’t appear. The only error that shows is if the user fails to enter a password entirely. The (locked) UmbLoginController has if/else statements that should make errors appear, but they’re not appearing – nothing beyond a page reload happens when the password is correct; I’ve even checked the page code to see if a class gets added anywhere, and that doesn’t appear to be the case.

Is there something that can be done to make an error text appear in case of an invalid login attempt?

Hi Mizzle,

I just had a play around, and I got the validation errors to show on the Login macro by changing the value of the asp-validation-summary tag helper from ModelOnly to All.



Here’s some info on what the asp-validation-summary tag helper does:

I’m not sure why the errors are not showing when it’s set to ModelOnly, as they are being set on ModelState in the UmbLoginController.cs, so they should be showing… How odd :thinking:

ModelState.AddModelError(string.Empty, "Member is locked out"); I believe would be for ModelOnly errors.. eg the empty string..

try adding a <span asp-validation-for="loginModel"></span> to see the property errors injected with that name in umbLoginController.

I think this is a subtle difference introduced in net.core over net framework.. ps multiple string.empty additions are aggregated together.

Thank you! I probably would have never found that. :blush:

No problem! :smiley:

By the way, just a heads up in case you plan on upgrading from v13 in the future, macros have been removed in Umbraco 14+.

Macros in general (i.e. ones used in Views) can be replaced using Partial Views, Tag Helpers or View Components; and Macros in Rich Text have been replaced with Blocks.

Just another heads up. I just tried this and it didn’t work for me. What did work was replacing:-

<div asp-validation-for="loginModel" class="text-danger"></div>

with

@Html.ValidationMessage("loginModel", "", new { @class = "text-danger" })

Hope this helps someone.