I am working on Asp.Net Core 6.0 MVC Razor pages. On the Login.cshtml page, I want to show the following error message when the user tries to login with in invalid credential: Invalid: User Name and/or Password. The problem is this message is displayed as a text instead of an html with the “User Name” and “Password” in bold. The following is my C# code in Login.cshtml.cs
var invalidLogin = await LockOut(Input.UserUserName, Input.Password);
if (!string.IsNullOrEmpty(invalidLogin))
{
invalidLogin = WebUtility.HtmlEncode(invalidLogin);
ModelState.AddModelError(string.Empty, invalidLogin);
return Page();
}
As shown above, I even tried to html encode the message. Still it’s displayed as a text, “Invalid: <b>User Name</b> and/or <b>Password</b>.”