03-09-2023, 03:18 PM
(This post was last modified: 03-09-2023, 03:45 PM by Mikael Nilsson.)
(03-09-2023, 01:01 PM)jeroen.rottink Wrote: This code redirects the user to SessionTimeout.html when the session timeout occurs.
Be sure to register the mimetype .html as static because it is served without session validation.
Code:procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
begin
// register my own exception handler
IWExceptionRenderer.SetExceptionRendererClass(TIWExceptionRendererEx);
// register mimetype .html without session validation
TIWMimeTypes.RegisterType('.html', 'text/html', True);
end;
{ TIWExceptionRendererEx }
class function TIWExceptionRendererEx.RenderHTML(AException: Exception; ARequest: THttpRequest): string;
var Addr: string;
begin
// the goal here is to respond to a session timeout error with a HTML which
// will restart a new session
if AException is EExpiredSession then begin
Addr := #39 + '/SessionTimeout.html' + #39; // wwwroot/SessionTimeout.html
Result := '<!DOCTYPE html>' +
'<html>' +
'<head>' +
'<script type="text/javascript">' +
'setTimeout("window.location=' + Addr + '", 1);' +
'</script>' +
'</head>' +
'<body>' +
'</body>' +
'</html>';
end
else
Result := inherited;
end;
Hi,
I tried your code. First in SA
I got 404 - Not found
http://127.0.0.1:8888/SessionTimeout.html
sorry I misspelled. It works

