@page
directive._Layout.cshtml
):<base>
tag to the <head>
element:href
value (the app base path) in the preceding example assumes that the app resides at the root URL path (/
). If the app is a sub-application, follow the guidance in the App base path section of the Host and deploy ASP.NET Core Blazor article._Layout.cshtml
file is located in the Pages/Shared folder in a Razor Pages app or Views/Shared folder in an MVC app.<script>
tag for the blazor.server.js script immediately before the closing </body>
tag:_Imports.razor
file to the root folder of the project with the following content (change the last namespace, MyAppNamespace
, to the namespace of the app):Startup.ConfigureServices
, register the Blazor Server service:Startup.Configure
, add the Blazor Hub endpoint to app.UseEndpoints
:App.razor
file to the project root with the following content:_Host.cshtml
file to the Pages
folder with the following content:_Layout.cshtml
file for their layout.App
component:Render Mode | Description |
---|---|
ServerPrerendered | Renders the App component into static HTML and includes a marker for a Blazor Server app. When the user-agent starts, this marker is used to bootstrap a Blazor app. |
Server | Renders a marker for a Blazor Server app. Output from the App component isn't included. When the user-agent starts, this marker is used to bootstrap a Blazor app. |
Static | Renders the App component into static HTML. |
_Host.cshtml
page to endpoint configuration in Startup.Configure
:App.razor
file to the root of the project with the following content:_Host.cshtml
file to the Views/Home
folder with the following content:_Layout.cshtml
file for their layout.App
component:Render Mode | Description |
---|---|
ServerPrerendered | Renders the App component into static HTML and includes a marker for a Blazor Server app. When the user-agent starts, this marker is used to bootstrap a Blazor app. |
Server | Renders a marker for a Blazor Server app. Output from the App component isn't included. When the user-agent starts, this marker is used to bootstrap a Blazor app. |
Static | Renders the App component into static HTML. |
_Host.cshtml
view to the endpoint configuration in Startup.Configure
:Pages
folder and add routable components to the app. For example:Counter
component:Counter
component is statically rendered with an initial value that's specified using a form. Since the component is statically rendered, the component isn't interactive:_ViewImports.cshtml
file. In the following example:MyAppNamespace
to the app's namespace.Components
to the folder where the components reside._ViewImports.cshtml
file is located in the Pages
folder of a Razor Pages app or the Views
folder of an MVC app.