MudBlazor: MudBlazor JS doesn't seem to work with the .Net 8 (RC 2) Blazor App template

Bug type

Other

Component name

No response

What happened?

Similar to #7510.
The resolution there was to add @attribute [RenderModeServer]. In RC2 the equivalent of that is @rendermode RenderMode.InteractiveServer. This fixed the JS issue but this affects the identity processes such as Register or Login. I get the following errors in the console.

` Exception thrown: ‘System.InvalidOperationException’ in System.Private.CoreLib.dll ‘Blazor8App.exe’ (CoreCLR: clrhost): Loaded ‘C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0-rc.2.23479.6\System.Reflection.Metadata.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled. Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Headers are read-only, response has already started.

System.InvalidOperationException: Headers are read-only, response has already started. at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.ThrowHeadersReadOnlyException() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.set_SetCookie(StringValues value) at Microsoft.AspNetCore.Http.ResponseCookies.Append(String key, String value, CookieOptions options) at Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager.AppendResponseCookie(HttpContext context, String key, String value, CookieOptions options) at Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) at Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties) at Microsoft.AspNetCore.Identity.SignInManager1.SignInWithClaimsAsync(TUser user, AuthenticationProperties authenticationProperties, IEnumerable1 additionalClaims) at Microsoft.AspNetCore.Identity.SignInManager1.SignInOrTwoFactorAsync(TUser user, Boolean isPersistent, String loginProvider, Boolean bypassTwoFactor) at Microsoft.AspNetCore.Identity.SignInManager1.PasswordSignInAsync(TUser user, String password, Boolean isPersistent, Boolean lockoutOnFailure) at Microsoft.AspNetCore.Identity.SignInManager1.PasswordSignInAsync(String userName, String password, Boolean isPersistent, Boolean lockoutOnFailure) at Blazor8App.Components.Pages.Account.Login.LoginUser() in C:\Users\devtr\source\repos\Blazor8App\Blazor8App\Components\Pages\Account\Login.razor:line 111 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'H82WxMerEA_MNs1Ydrx3bTrKW3-Ko3dTwzMe4X4RcQI'.

In Login.razor, line 111 is SignInManager.PasswordSignInAsync.

Expected behavior

For JS to work smoothly

Reproduction link

None

Reproduction steps

#7510

Relevant log output

No response

Version (bug)

6.11.0

Version (working)

No response

What browsers are you seeing the problem on?

Firefox, Chrome, Microsoft Edge

On what operating system are you experiencing the issue?

Windows

Pull Request

  • I would like to do a Pull Request

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Reactions: 2
  • Comments: 15 (5 by maintainers)

Most upvoted comments

For anyone interested I was able to select the render mode properly without setting it globally. Not every layout works this way, but a fixed drawer can work with SSR since the MudLayout doesn’t need to change afterwards.

image

And both the theme provider and the drawer works. I haven’t tested the other providers but I guess I can make them work the same way I made the ThemeProvider work (I haven’t posted this yet, if you need it I am happy to provide how I got it to work without setting interactivity globally).

I posted the details in here: https://github.com/MudBlazor/MudBlazor/issues/7511#issuecomment-1803776195

Thanks for posting this. It’s kinda surprising since SSR is really niche and I don’t see that many component authors will support it.

Hi @anthonyprabowo, I think that one is related to this: https://github.com/dotnet/aspnetcore/issues/51216 which is a bug on Blazor itself that apparently will be fixed on .Net 8 GA. I experienced it too.

Here is one more tidbit. To make MudBlazor play well with Identity in .net 8 the out of the box solution of WebApp won’t work. However, creating a solution like .net 7 with API and front end as separate projects works. One caveat is creating all the screens (razor components) like Login.razor etc yourself. I am pretty sure many figured this out as the both run separately. Hope this helps someone.

Identity gets broken

Maybe it would make sense to create the issue in MS repository? I see no reason why it shouldn’t work with interactive router, considering that some features require it.

I understand this has to with SSR in .net 8. Even Fluent-UI has the same issue. Any timetime of what the resolution could be. I am creating my components from scratch with TailwindCSS as I cant find any readymade solution yet.

Same issue, but I was unable to resolve the issue with RenderMode.

My scenario is a MainLayout with a simple button component with a click event handled in the code behind of the layout file, which never fires.