I have built a Blazor .NET 9 web app that has the @rendermode="InteractiveServer"
set in the App.razor
file.
In my MainLayout
, I have
protected override void OnInitialized()
which just creates an instance of a class and then in the
protected override async Task OnAfterRenderAsync(bool firstRender)
method, I build the page which is dynamically created from the database (no static files in this website). I have to build the pages here in the OnAfterRenderAsync
as I need to grab the users cookie details to get their user details and if I put in the OnInitialized
then I get thrown a JSOp error.
All runs great, builds the website pages and displays to the user great but when I "view source" of the page in the browser, there is no html apart from the blazer style links and the script tags, no header or body text, things like:
<body><!--Blazor:{"type":"server","prerenderId":"ec741368070d42e89a1ad871ff4ea12d"
<!--Blazor:{"prerenderId":"ec741368070d42e89a1ad871ff4ea12d"}-->
<!--Blazor-Web-Initializers:WwogICJfY29udGVudC9UaW55TUNFLkJsYXpvci9UaW55TWNlLkJsYXpvci5saWIubW9kdWxlLmpzIgpd--><!--Blazor-Server-Component-State:CfD
If I don't view source but instead click inspect (using google chrome browser), it will show the HTML.
My issue is google webmaster tools doesn't see the html text when it crawls the site and gives errors that all pages have the same data (the style and script tags) and no html so google won't index my website.
What do I need to do to push the HTML into the page so that when a user clicks on view source it sees the actual html?
Regards
J