In a Blazor server application, I have implemented user authentication via cookie. In the Blazor page (not razor view) I have created a form with email and password entries as well as a button for sending the data. The method is Post and is run on the server via a controller. In the controller I then check the form entries and verify the user by checking his name and password in the database.
So far, everything works as expected.
My problem, however, is the message in the event of an incorrect login (e.g. password is incorrect). I have been looking for a solution and the only solution is a communication between controller and Razor-View (.cshtml) via ViewBag. This is not possible in my case because I use a Blazor page and the login window is part of the Blazor navigation (in other words, I would have to do it like in the Microsoft login template by redirecting login to a separate Razor view .cshtml and I don't want that).
I only have one idea at the moment, but I don't like it. The approach would be to create a static class and use it as a link between the controller and the blazor page. Then I can use the information I set in the controller (e.g. login failed) to generate a corresponding message in the Blazor page. Of course, I would have to generate a GUID in addition to the email and password so that I can distinguish the logged-in user from all the other app-users.
So the question is, is there another way to generate a message (also e.g. simple JS alert) based on controller information in the Blazor page?
Thanks