79731129

Date: 2025-08-10 09:51:11
Score: 0.5
Natty:
Report link

Regarding your first question:

As I read from this source: I am trying to create cookie while login with a user in Blazor web server app but I am bit lost setting a cookie over Blazor Interactive Server ist not possible, since it uses SignalR. Cookies cannot be set over already started responses (what SignalR is).

You can load the login page in server mode. The problem is posting the form. If you try doing it like this:

<EditForm Model="Input" method="post" OnValidSubmit="LoginUser">

The LoginUser method is called directly on the server via SignalR.

Try something like this:

<EditForm Model="Input" method="post" action="/Account/Login" formname="login">

[SupplyParameterFromForm(FormName = "login")]
private InputModel Input { get; set; } = new();

As far as I tested, this will make sure the EditForm is posted to the server while every other component can still be interactive. I am not sure how this affects the LoginUser method to be called or not. But this could be a start for you.

Second question:

What do you mean by that? You cannnot alter the AuthenticationStateProviders to "enable" cookie setting over SignalR. This is simply not possible. The AuthenticationStateProviders revalidates your login cridentials every 30 minutes (default).

Third question:

I would suggest to you to use the static login page. Why do you need interactive mode anyway on the login page? If you want some sort of animation, you could do that with javascript instead.

Reasons:
  • Blacklisted phrase (1): I am trying to
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: S Mxller