Hi All,
I am getting below logs many times.
Invalid call of the 'RedirectToLogin' client action of the 'MainFlow.Homepage' since the latter is not currently active. This is likely due to a platform's client action being used as an event handler or in a setTimeout function. Consider removing this call by using the 'On Destroy' event of the screen/block or moving your logic to a global client action.
ControllerDisposedException: Invalid call of the 'RedirectToLogin' client action of the 'MainFlow.Homepage' since the latter is not currently active. This is likely due to a platform's client action being used as an event handler or in a setTimeout function. Consider removing this call by using the 'On Destroy' event of the screen/block or moving your logic to a global client action.Q:727:10)
Details:
1- I have created a Javascript node to check user inactivity on screen/window,
2- I have added that JS node to OnReady of parent layout block and assigning timeout value from Site-property.
3- Now if user is inactive till timeout value(in Minutes), logging out user and redirecting user to login screen using 'RedirectToLogin' client action, inside javascript function.
And now getting above log errors on service center multiple time. Please find below details. Please help me on this
Please suggest steps to resolve this error log from service center as Its coming very frequently...
Thanks,
Dileep
Hi, this is probably caused by the fact that the timer continues to run even when the homepage is out of context, which is why they suggest stopping it in an OnDestroy event. So add a function stopTimer() that kills it and call it in OnDestroy of the homepage.
Neil.
Neil Munro wrote:
Hi Neil, thanks for the reply, can you please explain little more. What I need to kill in On Destroy??
Its giving log for RedirectToLogin client action that I am calling once screen is idle, and redirect to login page.
Thanks
Dileep Verma wrote:
You need to destroy all the things that you created in OnReady that are global: so call cleartimeout(timeoutid) and remove the event listeners. Otherwise the events will continue to fire, resetting/restarting the timer, even after you have logged out...
Hi Thanks for the suggestion, I have removed all javascript event listener also clear timeout in onDestroy of layout block but still after logged out its getting called and try to find the client action "RedirectToLogin " but on login its not available..so please help me what code i need to write to remove event listener and cleartimeout.?
Dileep.
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener
document.removeEventListener("mousemove",resetTimer,false); //same params!
clearTimeout(timeoutId);
But it might be simpler to add a global var and set it to false on destroy:
var EnableTimeout = true;
function doinactive() {
if (EnableTimeout) $actions.RedirectToLogin();
}
...
OnDestroy:
EnableTimeout = false;
Hi Dileep,
I think u need to remove event listener added in the Destroy action of the screen.
Ajith
Ajithkumar Radhakrishnan wrote:
Hi Ajith, yes its something related to that, by looking the above code can you please let me know the what steps I need to follow to avoid this logs...
Hi Dileep
I was having a similar error and needed to remove the events in the OnDestroy, so I created a script with the event handler function:
function ResetTimer() { //Your timer action here };
then I assigned the script to the screen (as a Required Script) and used the AddEventListener in the OnReady:
document.addEventListener("keypress", ResetTimer, false);
and the RemoveEventListener in the OnDestroy:
document.removeEventListener("keypress ", ResetTimer , false);
Hope it helps!