Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
class function TIWExceptionRendererEx.RenderHTML
#7
(04-07-2023, 08:50 PM)Alexandre Machado Wrote: You need to declare a variable of type TIWUserSession to assign the value to.

In the example above I used UserSession but probably the compiler is trying to use the UserSession function. Use a different name instead:

as I mentioned before, I'm assuming you have access to the WebApplication. If not, use gGetWebApplicationThreadVar() instead. The complete code should be:

Code:
uses
  UserSessionUnit, IWApplication;

procedure DoSomethingWithUserSession();
var
  WebApp: TIWApplication;
  theUserSession: TIWUserSession;
begin
  WebApp := gGetWebApplicationThreadVar();
  theUserSession  := nil;
  if Assigned(WebApp) then  // there is no guarantee that a TIWApplication instance exists when an exception is raised
    theUserSession := TIWUserSession(WebApp.Data);
  if Assigned(theUserSession) then
  begin
    // do what you have to do with the UserSession here
  end;
end;

Hi,

Unfortunately it seems that the TIWApplication instance don't exists when an exception is raised.
So I guess that is it. Or is it another solution?

I hope you understand I'm doing this code in the ServerController?
Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)