skip to Main Content

I have implemented a login form that utilizes the login controller, which serves as a base controller. While the controller functions properly, my concern lies with error handling. Regrettably, I am unable to display error messages within the form as there is no means to return error messages from the controller. I would greatly appreciate any assistance in resolving this issue.
enter image description here
enter image description here

2

Answers


  1. You could try return error message using ViewBag

    ...
                try
                {
                    await HttpContext.SignInAsync(principal);
                }
                catch (Exception ex)
                {
                    ViewBag.Error = ex.Message;
                }
    ...
    

    Then use @ViewBag.Error in razor to display message.

    Login or Signup to reply.
  2. Please refer to the Microsoft documentation at the following link:

    Microsoft Documentation – ASP.NET Core MVC Validation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search