I have an issue that really keeps me struggling for a long time.
I am building a wizard, with multiple pages and I want to persist state from one page to the other. One step in that multi-page-wizard is performing an oAuth redirect to an external service (so, I show a <a href="" />
link that points to the oAuth login page, and after the login , the redirect from that service comes back to the next page in my wizard).
That all works, but the problem is that the state that I have persisted in ProtectedSessionStorage
seems to be gone after that redirect. I was in the assumption that that state would be persisted? (I tried both ProtectedSessionStorage
and ProtectedLocalStorage
)
I must be missing something, but I can't get my head around it.
This is the behavior until now:
- Page 1 : user enters value, value gets persisted to local storage
- Page 2 : I successfully load and display that value and add a link to the other application
- Page 3 : the other application redirects to this page, and when I execute the same code as on Page 2 (see below), the value is empty.
This is the code where the value is successfully retrieved on Page 2, and is empty on Page 3:
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var re = await SessionStorage.GetAsync<string>("LockExternalRef");
Console.WriteLine(re.Value); // Works on Page 2, empty on Page 3, after redirect
await base.OnAfterRenderAsync(firstRender);
}
}