[doc] GatewayToPremium - Skip this page next time - the page is not skipped
Closed this issue · 3 comments
hakenr commented
Does not work as expected
cc @Harvey1214
Harvey1214 commented
hakenr commented
@Harvey1214, both features have issues:
- The
<PageCanonicalUrl>
withHeadContent
assumes it's the only<HeadContent>
provider (sinceHeadOutlet
doesn’t merge multipleHeadContent
instances - the "last wins" rule applies), which is too restrictive. - The
GatewayToPremium
injects a<script>
tag directly into the existing page, which isn’t supported in Blazor. Even Static SSR requires careful handling: https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/static-server-rendering?view=aspnetcore-8.0, check out the newHxToast
implementation for reference.
We need to address this on both sides:
-
The
<PageCanonicalUrl>
should be modified to avoid blocking other<head>
extensions while keeping the usage simple. I’m planning to change it to something like<MetadataHeadContent>
, allowing additional head content to be appended. -
The
GatewayToPremium
needs a Blazor-compatible approach for the entire flow. Let's split the scenario into two steps:- The URL
/premium/access-content?url=...
will be handled by the server (controller only). Based on whether a cookie is present in the request, it will either redirect the user to the target URL immediately (without involving Blazor on the server or client) or redirect the user to: - A second Blazor server URL with the
GatewayToPremium
content (let's use a URL like/premium/access-content-gateway?url=...
).
- The URL
hakenr commented
From our in-person discussion:
- Instead of using the controller, we can handle the redirect during component server prerendering.
- We’ll merge steps i. and ii. above into a single Blazor component. This component will perform a cookie check and optionally handle the server redirect during prerendering. For WASM interactive rendering, it will use a JS
getSkipCookieValue
function, along withNavigationManager.NavigateTo()
based on the result.