Interactive SSR RCs in global WASM/Auto projects (#32844)

pull/32907/head
Luke Latham 2024-06-20 12:27:56 -04:00 committed by GitHub
parent 48e6414942
commit 42508d0073
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -397,7 +397,16 @@ In the following example, the render mode is set interactive SSR by adding `@ren
}
```
If using the preceding component locally in a Blazor Web App, place the component in the server project's `Components/Pages` folder. The server project is the solution's project with a name that doesn't end in `.Client`. When the app is running, navigate to `/render-mode-2` in the browser's address bar.
If using the preceding component in a Blazor Web App, place the component in the server project's `Components/Pages` folder†. The server project is the solution's project with a name that doesn't end in `.Client`. When the app is running, navigate to `/render-mode-2` in the browser's address bar.
> [!IMPORTANT]
> †If the app adopts global WebAssembly or global Auto rendering via the `Routes` component, individual components that specify interactive SSR (`@rendermode InteractiveServer`) in their component definition file (`.razor`) are *placed in the `.Client` project's `Pages` folder*.
>
> Placing interactive SSR components in the `.Client` project is counter-intuitive because such components are only rendered on the server.
>
> If you place an interactive SSR component in the server project's `Components/Pages` folder of a global WebAssembly or Auto app, the component is prerendered normally and briefly displayed in the user's browser. However, the client-side router isn't able to find the component, ultimately resulting in a *404 - Not Found* in the browser.
>
> Therefore, place interactive SSR components in the `.Client` project's `Pages` folder if the app adopts global WebAssembly or global Auto rendering via the `Routes` component.
## Client-side rendering (CSR)

View File

@ -581,6 +581,16 @@ The <xref:Microsoft.AspNetCore.Builder.AuthorizationEndpointConventionBuilderExt
:::zone-end
## Adding components that adopt interactive server-side rendering
Because the app uses global Interactive Auto rendering via the `Routes` component, individual components that specify interactive server-side rendering (interactive SSR, `@rendermode InteractiveServer`) in their component definition file (`.razor`) are *placed in the `.Client` project's `Pages` folder*.
Placing interactive SSR components in the `.Client` project is counter-intuitive because such components are only rendered on the server.
If you place an interactive SSR component in the server project's `Components/Pages` folder, the component is prerendered normally and briefly displayed in the user's browser. However, the client-side router isn't able to find the component, ultimately resulting in a *404 - Not Found* in the browser.
Therefore, place interactive SSR components in the `.Client` project's `Pages` folder.
## Redirect to the home page on signout
When a user navigates around the app, the `LogInOrOut` component (`Layout/LogInOrOut.razor`) sets a hidden field for the return URL (`ReturnUrl`) to the value of the current URL (`currentURL`). When the user signs out of the app, the identity provider returns them to the page from which they signed out.