Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
class function TIWExceptionRendererEx.RenderHTML
#3
(04-07-2023, 12:17 AM)Alexandre Machado Wrote: I suppose that within your code you have access to your WebApplication instance, is that correct?

The property Data of the WebApplication contains a reference to your UserSession object:

UserSession := TIWUserSession(WebApplication.Data);

However, the typecast will require you to link the unit with this code to the UserSessionUnit where TIWUserSession is declared.

Another alternative is to use the UserSessionBase (the parent class of your UserSession) Clipboard object to temporarily store some values that are needed elsewhere. Something like:

uses
  IWUserSessionBase;

UserSession := TIWUserSessionBase(WebApplication.Data); 

// Store the value there
UserSession.Put("LoggedUser", "Mikael Nilsson"); 

// Store the value there
UserName := UserSession.Get("LoggedUser");

Note that in this example I don't need to link with the UserSessionUnit, only with the IWUserSessionBase unit which is part of the IW not your application. You can have a more generic approach using this.

Hi,

Sorry I don't understand thcode.  It's hard for me to understand what procedure/function you have assigned that code.

What I understand  TIWExceptionRendererEx.RenderHTML(AException: Exception;  ARequest: THttpRequest): string; executes first and then 
TIWServerController.IWServerControllerBaseCloseSession(aSession: TIWApplication);

I want to send a value from TIWExceptionRendererEx.RenderHTML to a variable in the userssion.
and then IWServerControllerBaseCloseSession use that variable so i can update my table with the exception class.

--------------------------------------------------------------------------------------------------------------------------------------------------
Reply


Messages In This Thread
RE: class function TIWExceptionRendererEx.RenderHTML - by Mikael Nilsson - 04-07-2023, 09:09 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)