#1 2025-08-04 07:40:33

testgary
Member
Registered: 2025-02-06
Posts: 25

ServiceMethodRegister CurrentSession

procedure TMvcApplication.Test(Ctxt: TRestServerUriContext);
var
  CookieData: TCookieData;
begin
  // There was an error in this place. Before, I could do it this way and it worked!
  // After synchronizing the latest code, here are the issues.
  if CurrentSession.CheckAndRetrieve(@CookieData, TypeInfo(TCookieData)) > 0 then;
end;  

procedure TMvcApplication.Start(aRestModel: TRest);
begin
  (aRestModel as TRestServerDB).ServiceMethodRegister('Test', Test, True, [mGET]);
end; 

Offline

#2 2025-08-05 09:18:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,123
Website

Re: ServiceMethodRegister CurrentSession

You are right, the core logic was changed.
We uncoupled the MVC process from TRestServer and TRestServerUriContext: we would like to add its feature directly at web server level (soon).

So inside a method-based service, there was no context information for the cookie any more...
I forgot about this valid use-case.

I have fixed this by defining a proper rendering class to consume the TRestServer information:
https://github.com/synopse/mORMot2/commit/f8171e604

Sorry for the inconvenience, and thanks for the report.

Offline

#3 2025-08-06 15:22:22

testgary
Member
Registered: 2025-02-06
Posts: 25

Re: ServiceMethodRegister CurrentSession

This URL is incorrect
http://localhost:8092/blog/mvc-info

Offline

#4 2025-08-06 15:59:08

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,123
Website

Re: ServiceMethodRegister CurrentSession

Please define "incorrect".

On my side, it seems fine:
Screenshot-2025-08-06-at-17-58-47-IBlog-Application-Information.png

Offline

#5 2025-08-07 04:52:50

testgary
Member
Registered: 2025-02-06
Posts: 25

Re: ServiceMethodRegister CurrentSession


I did nothing. I used the "mvc-blog" example.

windows 11
Lazarus 4.0RC3 (rev lazarus_4_0RC3) FPC 3.2.2 x86_64-win64-win32/win64

#0 TWrapperContext.ContextFromRtti(nil, wUnknown, TRttiCustom($000000000169C3C0), '', '') at mormot.soa.codegen.pas:685
#1 TWrapperContext.ContextArgsFromMethod(nil, TInterfaceMethod (''; ''; ''; 0; []; []; 0; 0; 0; 0; nil; 0; 0; 0; 0; 0; 0; 0; 0; 0; []; 100398128; nil; (''); nil; (4, 0, 0, 0, 0, 0, 0, 0, 187, 179))) at mormot.soa.codegen.pas:886
#2 TWrapperContext.ContextFromMethod(TWrapperContext($0000000005FBF278), Failed to read data from register (while calculating location)) at mormot.soa.codegen.pas:938
#3 TWrapperContext.ContextFromMethods(TWrapperContext($0000000005FBF278), Failed to read data from register) at mormot.soa.codegen.pas:994
#4 ContextFromMethods(Failed to read data from register) at mormot.soa.codegen.pas:1128
#5 TMvcApplication.GetMvcInfo(TMvcApplication($0000000005FBF278), Failed to read data from register (while calculating location)) at mormot.rest.mvc.pas:2663
#6 TMvcRunWithViews.ComputeMvcInfoCache(TMvcRunWithViews($0000000005FBF278)) at mormot.rest.mvc.pas:2084
#7 TMvcRunOnRestServer.InternalRunOnRestServer(TMvcRunOnRestServer($00000000016018D0), TRestServerUriContext($0000000007499710), 'mvc-info') at mormot.rest.mvc.pas:2220
#8 TMvcRunOnRestServer.RunOnRestServerRoot(TMvcRunOnRestServer($0000000005FBF278), Failed to read data from register) at mormot.rest.mvc.pas:2298
#9 TRestServerUriContext.ExecuteSoaByMethod(TRestServerUriContext($0000000005FBF278)) at mormot.rest.server.pas:3264

Offline

Board footer

Powered by FluxBB