We have a Blazor application that is using the newer InteractiveAuto rendering mode. We have started down a path, but have discovered an issue with our pages: none of them can be directly accessed.
First, a small explanation of what we are working with. We have Services that connect to an external API. This is how we get our data. Pretty standard.
We are using Blazored Session Storage to store a Selected Customer.
We are doing this to avoid needing to place the customer id in the route and then reload that data from the server over and over, and in our experience, storing it in memory was too volatile because if the circuit resets we lose the data - which happened way too frequently
our current approach on a page/component looks something like this:
protected override async Task OnInitializedAsync(){ //get selected customer from local storage //get data from API service using info from selected customer}If we come to that page via a NavLink or NavigationManager this all works very nicely.
But, when we try to hit the page directly by typing in the URL, We get a JSinterop error because Blazored is using JSinterop to access local storage, which is not available during static prerendering.
Is there a way to disable static prerendering on a page by page basis, or am I going to have to go through and rework all of my pages and components that rely on this selected customer information to do data retrieval in OnAfterRenderAsync - which is less ideal because page loads blank and then content blinks into existence depending on server lag and the time it takes for the data to return.