Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: URL handling via TContentHandler seems not work anymore in IW 14.2.6



Permlink Replies: 4 - Last Post: Feb 22, 2018 1:20 AM Last Post By: Alberto Pilat
Alberto Pilat

Posts: 6
Registered: 4/10/00
URL handling via TContentHandler seems not work anymore in IW 14.2.6
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 6:28 AM
Hi,
our web application must be able to respond to a request made to a specific URL (es. http ://ourserver:8888/mycustomurl).
In IW 12 we used the TIWURLResponderEvent class for this; during the migration to IW 14 we rewrote those parts of our code in order to use the new
TContentHandler, as recommended in the IW documentation (https://www.atozed.com/intraweb/docs/v14/develop/content-handlers/).
During our first test phase, using IW 14.1.14, this functionality worked fine.
However when we updated IW to the latest version available (14.2.6) the custom URL handling stopped to work (we always get a blank page on the browser).
This behavior occurs when the AllowMultipleSessionPerUsers property of the server controller is set to True, otherwise everything works well.
Our TContentHandler derived class also set its own CanStartSession to True. If I set this property to False, the main form page is always displayed (the Execute() method of our
content handler is not executed at all).

We wrote a minimal test project and the results were the same: using IW 14.1.14 and IW 14.2.0 everything works fine, with IW 14.2.6 it doesn't.

We compared the responses that are sent by IW 12 and IW 14 servers to the client: in IW 12 we saw that our content (written via THttpReply.WriteString() ) is immediately sent to the browser.
In IW 14 instead,we saw an HTML page with some Javascript code that, we suppose, makes a request via XMLHttpRequest to the web server demanding for the real content of the page, then
place this content in the document.
This Javascript seems to be changed in the latest versions of IW 14: if we create an HTML page including the old Javascript and we place a proper URL as
parameter for the JavaScript get() function declared in the page, everything seems to work again. So we are thinking there is something different in the new JavaScript code.

How can we get ourcontent handler to work?

We can provide the sample program if you a need a test case.

Thanks in advance.
Marco Gallizio

Alberto Pilat
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: URL handling via TContentHandler seems not work anymore in IW 14.2.6
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 4:40 AM   in response to: Alberto Pilat in response to: Alberto Pilat
Hi Alberto, i think is better for you do this in ServerController:
initialization
  TIWServerController.SetServerControllerClass;
 
  // This maps the login url our custom class Tmycustomurl.
  // So, something like http://127.0.0.1:8888/mycustomurl will be redirected to
  // this handler.
  with THandlers.Add('', 'mycustomurl', Tmycustomurl.Create) do begin
    CanStartSession := True;
    RequiresSessionStart := False;
  end;
 
end.

and in your content
function Tmycustomurl.Execute(aRequest: THttpRequest; aReply: THttpReply; const aPathname: string; aSession: TIWApplication;
 aParams: TStrings): boolean;
begin
  Result := True;
  if Assigned(aReply) then begin
    aReply.ContentType := MIME_XML;
    aReply.WriteString('<xml>My xml content here</xml>');
  end;
  aSession.Terminate;
end;

Get from here: https://github.com/Atozed/IntraWeb/tree/master/XIV/Delphi/CustomContentHandlers
Alberto Pilat

Posts: 6
Registered: 4/10/00
Re: URL handling via TContentHandler seems not work anymore in IW 14.2.6
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 6:32 AM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
Hi Jose.
thanks for your answer.
We performed some other tests based on your hints and setting the property RequiresSessionStart to False seems to make the content handler work correctly.
For some reason in IW 14.1.14 even if we don't set this property to False everything works fine. In IW 14.2.6 this doesn't happen and we get a blank page instead.
Using the Javascript generated by IW 14.1.14 on a page served by IW 14.2.6 makes all the stuff works. Don't know why.

The example we used for our tests was based on the instructions in the URL & Content Handlers section of the documentation (the URL we posted before, that meanwhile
has been moved to https://doc.atozed.com/atozed/en/iw14/develop/content-handlers/) and it has some little differences respect to the examples on the GitHub repository
(the RequiresSessionStart was not set, maybe at the time the page was written this operation was not needed?).

May we ask you a last thing, what the RequiresSessionStart property do? We searched in the official documentation but we didn't find this property anywhere... the most similar property listed is RequireSession (see https://doc.atozed.com/atozed/en/iw14/develop/classes/classes/tcontentbase/) but TContentBase in IW 14.2.6 seems not to have such property...

Thanks in advance.
Marco Gallizio
Alberto Pilat
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: URL handling via TContentHandler seems not work anymore in IW 14.2.6
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 7:18 AM   in response to: Alberto Pilat in response to: Alberto Pilat
May we ask you a last thing, what the RequiresSessionStart property do? We searched in the official documentation but we didn't find this property anywhere... the most similar property listed is RequireSession (see https://doc.atozed.com/atozed/en/iw14/develop/classes/classes/tcontentbase/) but TContentBase in IW 14.2.6 seems not to have such property...

My understanding of this is we need CanStartSession := True; to execute, but the session start redirection (/$/SessionStart) is executed and break our code. Because off this we need to RequiresSessionStart := False;

In short RequiresSessionStart control start redirection (/$/SessionStart).
Alberto Pilat

Posts: 6
Registered: 4/10/00
Re: URL handling via TContentHandler seems not work anymore in IW 14.2.6
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 22, 2018 1:20 AM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
Thank you Jose, you have been very kind.

Have a nice day!
Goodbye

Marco Gallizio
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02