The type or namespace name 'RenderModeServerAttribute' could not be found (are you missing a using directive or an assembly reference?)

Developer 60 Reputation points
2023-11-26T12:36:07.1966667+00:00

In .Net 8 preview version I was using below code in .razor file

@using Server.Models;
@page "/movies/signalr"
@attribute [RenderModeServer]
@inject HttpClient Http

This is with blazor signalR render mode.

But in the final release version of .Net 8, I am getting the below error for @attribute [RenderModeServer]

The type or namespace name 'RenderModeServerAttribute' could not be found (are you missing a using directive or an assembly reference?)

Below one works, so I am assuming, it got changed in final release

@attribute [StreamRendering(true)]
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,335 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,132 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,373 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ping Ni-MSFT 2,085 Reputation points Microsoft Vendor
    2023-11-27T03:40:28.0166667+00:00

    Hi @Developer,

    In .NET 8, you need use @rendermode attribute.

    Sets the render mode of a Razor component:

    • InteractiveServer: Applies interactive server rendering using Blazor Server.
    • InteractiveWebAssembly: Applies interactive WebAssembly rendering using Blazor WebAssembly.
    • InteractiveAuto: Initially applies interactive WebAssembly rendering using Blazor Server, and then applies interactive WebAssembly rendering using WebAssembly on subsequent visits after the Blazor bundle is downloaded.

    More details refer to: @rendermodel definition


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Rena

    3 people found this answer helpful.

0 additional answers

Sort by: Most helpful