一键导入
render-info
Using the RendererInfo class in Blazor to detect rendering context and interactivity.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Using the RendererInfo class in Blazor to detect rendering context and interactivity.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | render-info |
| description | Using the RendererInfo class in Blazor to detect rendering context and interactivity. |
The RendererInfo class in Blazor provides runtime information about the renderer that is executing the component. It is particularly useful for detecting whether a component is running interactively or statically, and for identifying the specific rendering platform (e.g., Server, WebAssembly, WebView).
IsInteractivebool@if (!RendererInfo.IsInteractive)
{
<p>Connecting...</p>
}
else
{
<button @onclick="HandleClick">Click Me</button>
}
Namestring"Static": Running in static server-side rendering (SSR)."Server": Running in Interactive Server mode (SignalR)."WebAssembly": Running in Interactive WebAssembly mode."WebView": Running in a Blazor Hybrid application (MAUI, WPF, WinForms).<p>Current Render Mode: @RendererInfo.Name</p>
When a component is prerendered on the server, event handlers (like @onclick) are not active. You can use RendererInfo.IsInteractive to disable inputs until the interactive runtime takes over.
<button @onclick="Submit" disabled="@(!RendererInfo.IsInteractive)">
Submit
</button>
You might want to show a simple HTML form for static SSR and a rich, interactive component for interactive modes.
@if (RendererInfo.Name == "Static")
{
<form action="/search" method="get">
<input name="q" />
<button type="submit">Search</button>
</form>
}
else
{
<SearchComponent />
}
AssignedRenderMode: A property on ComponentBase that tells you which render mode was assigned to the component (e.g., InteractiveServer, InteractiveWebAssembly, InteractiveAuto). Note that AssignedRenderMode might be null during static rendering.RendererInfo is available in .NET 8.0 and later.