Вот мой рабочий компонент (упрощенно):
Код: Выделить всё
// SessionTimeout.razor
@inherits SessionTimeoutBase
@using Microsoft.AspNetCore.Mvc.TagHelpers;
Session Time Remaining:
// ... rest of component
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
module = await JSRuntime.InvokeAsync("import", "./Components/SessionTimeout.razor.js");
await module.InvokeVoidAsync("timer", OriginalTimeout, SessionWarning, TimeoutCount);
}
}
}
Код: Выделить всё
// ConsentModal.razor
@inherits ConsentModalBase
@namespace TCore.Components
@inject ILogger logger
Consent Agreement
[Your consent agreement text here]
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
logger.LogInformation("ConsentModal OnAfterRenderAsync attempting to run"); // Never gets hit
if (firstRender)
{
try
{
module = await JSRuntime.InvokeAsync("import", "./Components/ConsentModal.razor.js");
await module.InvokeVoidAsync("initializeConsent");
}
catch (Exception ex)
{
logger.LogError(ex, "Error in OnAfterRenderAsync");
}
}
}
}
Код: Выделить всё
// Working SessionTimeout component
// Problematic ConsentModal component
@if (!isConsentAgreed && !isConsentPage && !isSessionLoggedOutPage && !isSessionExpiredPage && (hasEDIPI == null))
{
}
Что может помешать вызову OnAfterRenderAsync в компоненте ConsentModal, когда он работает нормально в SessionTimeout?
Подробнее здесь: https://stackoverflow.com/questions/793 ... ndered-fro
Мобильная версия