After some research, I understood that Blazor and ASP.NET MVC are two completely different approaches that are difficult to combine. With Blazor, everything is much simpler because all the application objects used are on the server side. In the MVC approach, the objects are split between the client and the server. For example, the user can enter data in a form, but with MVC the server only knows the values when they are transferred to the server. With Blazor, these input values are immediately visible because there is a copy of the DOM on the server.
I have read in many places that Microsoft recommends a combination of Blazor Razor pages and MVC Razor (cshtml), which is also evident in the Microsoft login framework. This may sound interesting, but I haven't figured out how to share values between a page (blazor) and a view (MVC) in combination with the controller. As far as I understand it correctly, you can't transfer a value from the controller to the blazor page!
Back to my problem:
After reading a lot of posts, I came to the conclusion that you have to query the database of the user input in the controller (username and password verification). Only when his input is verified, the controller is allowed to send an instruction to the client to save the cookie on the client.
I do all this now and it works, however I have another problem and that is I don't know how to generate a notification if the user has entered a wrong password? This would be very easy if I use cshtml Razor View (e.g. via ViewBag and HTML code in the view), but since I use Blazor Razor, there is no way I can send anything to Blazor Page from the controller (e.g. a messagebox via JavaScript).
If anyone knows anything else, I would be very grateful for a tip.
Thanks
I'm not sure why the password is needed after a successful login.
If the user has entered their email and password in the form, then I need to have both values within the Blazor app on the server so that I can verify the user in the database.
I would like to ask a couple of very basic questions about the client-server process:
If the user has entered email and password in the form and pressed submit button, then the form sends the values to the server, right? On the server, the values end up in the controller, which in turn sends a request to the client via:
await HttpContext.SignInAsync(claims);
to save a cookie on the client.
If that's the case, then I should actually attack the form values in the controller and cache them somewhere so that I can use them in the rest of the Blazor Server app, right? What would be the usual (or correct) approach here?
Thanks
I have not heard from you for a couple of days. Please let me know if there is anything that I can help here.