PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Ping Peter Holemans.
Ping Peter Holemans.
Débuté par Aad Gouka, 06 aoû. 2017 14:25 - 15 réponses
Posté le 06 août 2017 - 14:25
Hi all,

I'd like to know if there is a way to "grab" the subdomain from a subdomain url like Customer.domain.com. What I need is handing Customer to Webdev. The reason for this is that a subdomain name determines which site and layout will be started.

So one application in Webdev with several customers and their specific layout(colors) and
starting page.

Anyone with ideas about this.

Best regards,

Aad
Posté le 07 août 2017 - 00:17
Hi

AFAIK, it's not a webdev problem, but a web server configuration problem.

I did it on IIS a few years back, and basically, it means setting up a different first page (static/htm) for each subdomain and in the htm page, redirecting toward your webdev site with a different parameter.

Another way is to use URL rewriting (whre Client1.domain.com=domain.com/Client.awp?ID=Client1
or something or the sort

Once again, not really a webdev problem

Now, if you want neither of the two solutions above, you should and you redirect ALL subdomain to the same page, you should be able to get the information by getting the whole URL (it's a system parameter) and extracting the subdomain.

Best regards
Posté le 07 août 2017 - 10:55
Fabrice, thanks for the information.

Do you know how to get the whole URL and extract the subdomain ?


Best regards,

Aad
Posté le 07 août 2017 - 11:55
Hi Add,

SysEnvironment() with the QUERY_STRING or REQUEST_URI parameter will give you the requested address before and after server interpretation.

Cheers,

Peter Holemans
Posté le 07 août 2017 - 12:26
Thanks Peter,

Would you be so kind to give me the exact syntax for this.
The Help won't take me any further.

TIA.

Best regards,

Aad G.
Posté le 08 août 2017 - 18:16
Ping Peter Holemans.
Posté le 09 août 2017 - 09:28
Hi Aad,

Testing locally in V21 and indeed can't get these variables back.
Either it is an undocumented change, either it is server only...
I'm sure I used these variables before to get the HTTP request address (V17 or so).
Do a full SysEnvironment in your project opening code to see what you have.

Trace(SysEnvironment()) Trace(ExtractString(SysEnvironment("QUERY_STRING"),2,"=")) Trace(ExtractString(SysEnvironment("REQUES_URI"),2,"="))
Cheers,

Peter Holemans
Posté le 09 août 2017 - 12:24
Thanks Peter,

I tried several variations, but nothing worked. (no values returned).

Best regards,

Aad
Posté le 09 août 2017 - 14:11
Hi

I confirm that this works in webdev (I'm using it on my web site) inside the project init code (but I'm not sure if it works somewhere else).

Best regards
Posté le 09 août 2017 - 14:22
Hi Fabrice,

I tried Peter's examples in the project Init code, local and on a server. No response. Perhaps you can give me an example ??

Best regards,

Aad
Posté le 09 août 2017 - 15:35
Hi

By example, in the project init code, I'm using:
gpasQueryString is ANSI string=SysEnvironnement("QUERY_STRING")

And I'm getting the information I need.

Best regards
Posté le 10 août 2017 - 10:34
Hi Fabrice,

Lucky you then, because I tried every possible combination and result is zero. I'm going to look at the option you mentioned in the beginning.

Best regards,

Aad
Posté le 10 août 2017 - 13:46
Hi Aad,

I can confirm to Aad that these variables are not returned in WB21 in a test environment on a Windows 10 Business machine. When doing a SysEnvironment() returning all possible SysEnvironment variables, these variables aren't even listed in there.
Haven't tested on a Windows 2012 or higher server with IIS though.

I guess Fabrice must be testing on a different configuration (Windows 7 or 8 machine with a different version of IIS).

Pfff... All this stuff is natively accessible and configurable in .net (Core) MVC via the routing paradigm and its routing engine directing any request to the appropriate controller based on the URL pattern and your configuration.

Raise a call with PCS Tech Support in this case I'ld say...

Cheers,

Peter Holemans
Posté le 10 août 2017 - 15:43
Hi

I have it working in webdev 19/AWP on a server 2008, and I just tested it in GO mode with webdev 22 under windows 10 without any problem, both in classic and awp mode.

The working code :
in the init of project:

gpasURL is ANSI string=SysEnvironment("HTTP_HOST") gpasPath is ANSI string=SysEnvironnement("PATH_INFO") gpasQueryString is ANSI string=SysEnvironnement("QUERY_STRING") asLanguage is ANSI string = SysEnvironnement("HTTP_ACCEPT_LANGUAGE")
in the only page of a test project
Declaration
PROCEDURE MyPage(MyPar is string)
Init:
Info("gpasURL="+gpasURL,"gpasPath="+gpasPath,"gpasQueryString="+gpasQueryString,"asLanguage="+asLanguage)
And I get as result in awp mode:
HTTP_HOST=localhost
PATH_INFO=/TESTSYSENV_WEB/UK/index.awp
QUERY_STRING=P1=testValue
HTTP_ACCEPT_LANGUAGE=en-US,en;q=0.5

This is on a win 10 development machine with IIS configured by webdev directly.

Best regards
Posté le 10 août 2017 - 16:19
Hi Aad,

Are you also working on a 'Dutch' Windows 10 64 bit as we're having the same result (It simply doesn't return those variables in the project init code)? Checked the same on an English Windows 2008 R2 server with IIS 7.5 on a deployed site. There it works...

IIS version on my dev machine=10.0.15063.0 / Windows 10 on my dev machine=Windows 10 Pro Dutch with all the latest patches applied.

Anyway, I don't need it anymore so I won't spend any more time on it...
Sorry I can't be of any more help here.

Cheers,


P.
Posté le 10 août 2017 - 16:25
Hi Peter,

Dutch W10 64 development and 2012 server English. Both no result. Thanks for your help though.

Thanks for the example Fabrice. I will look into it.


Best regards,

Aad