Handling session timeout and other errors

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!

I’m trying to create some kind of application where the user has to login to access secured content. What I want to achieve is handling all possible errors, react in a certain way and do NOT display the built-in default error messages.

1) Session Timeout:
When a user successfully logged in and the application times out (Application_SessionTimeout event) I want to display the login form again and set a label control to something like “You’ve been logged out due to session timeout!”.
During development I keep the default “sessionTimeout” of Default.json to get the Session_Timeout event after 60 seconds (1 minute) of user inactivity. As I understood this event should be raised at half of the time of seesionTimeout !?

In the Application_SessionTimeout I used the following code:

if (Application.MainPage.ToString() != “Login”)
Application.MainPage = new Login(“Your session has timed out”);¬†¬† // which allows me to set the message
Application.MainPage = new Login();
e.Handled = true;

But it seems the session timeout does occur reliable. In all my tests the event was raised (far) later as it should be raised. Sometimes up to 5 or 10 minutes later. Is there a way to check what’s going on ?

2) Other Errors and/or exceptions:
What I’ve found so far there are some errors which have to be catched on client side handled in
the Default.html:

a) Network Error:
Wisej.onNetworkError = function (type, error) {
// handle a network error
TODO: Redirect to the Login Page and display error information

Wisej.onException = function (ex) {
if (ex.invalidSession) {
// handle a invalid session exception
TODO: Redirect to the Login Page and display error information
else {
// handle a general exception
TODO: Redirect to the Login Page and display error information

So in case of these client side errors I want to redirect the user to the Login Page again (with new session if needed) on the same browser tab and display a text in a label of the Login Page to show the reason for the logoff.
A great addition would be in case of a network error to display the loading spinner until the connection is back again…

But I found no way to do that. Maybe you can give me a hint how this can be implemented ?
In addition are there any more error “events” which are handeled by WiseJ I can to overwrite
if I need to ?

Thank you very much in advance.

  • You must to post comments

Hi Luca,
thanks for clarification about the SessionTimeout.
But is there any possiblity from the client side (Java script) e.g. in case of the network error to call the Login form again with some parameter (text: You’re logged out due to network error) or set a label of this form to a certain text ?

  • You must to post comments

Answers below:

Session Timeout

The session timeout set in Default.json is the timeout used to fire OnSessionTimeout. The “real” session timeout set in the cache for the automatic destruction of the session is session-timeout * 2. The SessionTimeout event is not the real timeout, it is not possible to recover a session after the real time out.

The event is not fired after the session timeout, it is fired after the session timeout since the last time any user activity has been detected.

[Edited: the part above is a bit wrong. When user activity is detected, the next session timeout is skipped. The actual firing of the event will occur at session-timeout + residual time from last user activity, or something like that…]

As soon as there is any activity that causes a request, wisej will skip the next session timeout. The reason is that the “real” timeout in the session cache is renewed automatically as soon as the session is retrieved. So a request to the server, any request, renews the session life time. The method Wisej.Core.userIsAlive() is called on mousemove, mousedown and keydown.

Client Side Errors vs Server Side Errors

Wisej.onNetworkError() and Wisej.onException(with ex.invalidSession = true) should be the only errors that cannot be handled by the server.

Otherwise  any call to Wisej.onException() is either from an exception generated on the server, or a bug on the client.

You can handle the application’s exception globally by attaching to:


The handler and the event args are part of System.Threading. Just by attaching to the event suppresses the default exception dialog.

To show the ajax loader on the client at any time, call Wisej.Core.showLoader(true|false);






  • You must to post comments
Showing 2 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json