Atozed Forums

Full Version: First Page from URL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi I have created a new Intraweb (standalone) app with two forms (blueform and greenform) and have given them URL aliases in the OnConfig handler of the server controller using:

void __fastcall TIWServerController::IWServerControllerBaseConfig(TObject *Sender)
{
TGreenForm::SetURL ("/", "Green.html") ;
TBlueForm::SetURL ("/", "Blue.html") ;
}

The green form is set as the main form

If I try to start a session from a browser with the URL: http://127.0.0.1:8888/Blue.html I don't get the blue form, I get the green form. How can I fix this please?

Once the session has been started, the URL does work

I have Intraweb 14.2.7 Ultimate edition, and am using C++Builder 10.2 update 3

Thanks
Ian
I believe you would use ContentHandlers for that, or use the ServerController.OnGetMainForm event to detect parameters.

ContentHandlers would seem to be the best fit.
https://doc.atozed.com/en/iw14/develop/c...-handlers/
(04-21-2018, 07:30 PM)DanielFields Wrote: [ -> ]I believe you would use ContentHandlers for that, or use the ServerController.OnGetMainForm event to detect parameters.

ContentHandlers would seem to be the best fit.
https://doc.atozed.com/en/iw14/develop/c...-handlers/

In addition to the doc page Daniel referenced, there are samples on Github at:

  https://github.com/Atozed/IntraWeb

There is apparently a C++ example of that in the directory "...trunk\XIV\C++\ContentHandlers", though I didn't try it.  The Delphi example is under the Delphi directory.

Dan
Thank you both for pointing me at the ContentHandlers example.

Unfortunately, it suffers from exactly the same problem.

The example defines three URLs /blueform.html /redform.html and /mydoc.html (which redirects to an external page) it also has am additional main form.

Starting the session using the URL http://127.0.0.1:8000/bluform.html in a browser does not give the blueform page, but gives the mainform instead. once the session has started the URL does indeed give the blueform.

Is this only a problem with C++ only?
(04-23-2018, 09:33 AM)AllBars Wrote: [ -> ]Thank you both for pointing me at the ContentHandlers example.

Unfortunately, it suffers from exactly the same problem.

The example defines three URLs /blueform.html /redform.html and /mydoc.html (which redirects to an external page) it also has am additional main form.

Starting the session using the URL http://127.0.0.1:8000/bluform.html in a browser does not give the blueform page, but gives the mainform instead. once the session has started the URL does indeed give the blueform.

Is this only a problem with C++ only?

You are correct, that example does require the main form to be executed in order to start the session.   I haven't done this specifically, as you are looking for, so I'm not going to be much more help.  But that doesn't keep me from making suggestions. <g>

You might look at CustomContenHandler.   I've used those before but as a different mission (serving up XML single message service).   I'm fairly sure that has some option to serve up a form, and maintain the session.  I just haven't had the need to look into it.

Another potential option, if you don't mind another "Splash style" form coming up initially is to allow a "Main" form to come up, but have that form launch your target.   I've done that by launching in an async timer event off the main form.  In my case I intentionally wanted a flash message to appear, but if you can make it look like you want that splash then it works great. 

But, again, I'm pretty sure there is a way to do exactly what you're looking for... I just don't know the details.  I'm pretty sure it will involve a CustomContentHandler.

Dan
CustomContentHandlers will work. I keep forgetting that there are two options in that area. The other option is to pass the form as a parameter. You could then use the OnGetMainForm event in the server controller.

Your URL would be a little different: http://mydomain.com:8888/$/start/?blue.html. The server would see "blue" as WebApplication.RunParams[0]. You would use that in your logic for the event.
(04-24-2018, 04:42 AM)DanielFields Wrote: [ -> ]CustomContentHandlers will work.  I keep forgetting that there are two options in that area.  The other option is to pass the form as a parameter.  You could then use the OnGetMainForm event in the server controller.

Your URL would be a little different: http://mydomain.com:8888/$/start/?blue.html.  The server would see "blue" as WebApplication.RunParams[0].  You would use that in your logic for the event.

That will work ok. thank you for the tip :-)

(04-24-2018, 12:16 AM)DanBarclay Wrote: [ -> ]
(04-23-2018, 09:33 AM)AllBars Wrote: [ -> ]Thank you both for pointing me at the ContentHandlers example.

Unfortunately, it suffers from exactly the same problem.

The example defines three URLs /blueform.html /redform.html and /mydoc.html (which redirects to an external page) it also has am additional main form.

Starting the session using the URL http://127.0.0.1:8000/bluform.html in a browser does not give the blueform page, but gives the mainform instead. once the session has started the URL does indeed give the blueform.

Is this only a problem with C++ only?

You are correct, that example does require the main form to be executed in order to start the session.   I haven't done this specifically, as you are looking for, so I'm not going to be much more help.  But that doesn't keep me from making suggestions. <g>

You might look at CustomContenHandler.   I've used those before but as a different mission (serving up XML single message service).   I'm fairly sure that has some option to serve up a form, and maintain the session.  I just haven't had the need to look into it.

Another potential option, if you don't mind another "Splash style" form coming up initially is to allow a "Main" form to come up, but have that form launch your target.   I've done that by launching in an async timer event off the main form.  In my case I intentionally wanted a flash message to appear, but if you can make it look like you want that splash then it works great. 

But, again, I'm pretty sure there is a way to do exactly what you're looking for... I just don't know the details.  I'm pretty sure it will involve a CustomContentHandler.

Dan

That might have worked, but Dan Fields solution is cleaner. Thank you for the suggestions.

This feels a lot like a bug to me though. The same URL gives different results depending on if the session has already been started or not.

Ian