Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
16
Erster Beitrag:
vor 1 Woche, 3 Tagen
Letzter Beitrag:
vor 6 Tagen, 5 Stunden
Beteiligte Autoren:
Aad Gouka, Peter Holemans, Fabrice Harari

Ping Peter Holemans.

Startbeitrag von Aad Gouka am 06.08.2017 12: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

Antworten:

Re: WebDev 22 - url subdomain -> WebDev.

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

von Fabrice Harari - am 06.08.2017 22:17

Re: WebDev 22 - url subdomain -> WebDev.

Fabrice, thanks for the information.

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


Best regards,

Aad

von Aad Gouka - am 07.08.2017 08:55

Re: WebDev 22 - url subdomain -> WebDev.

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

von Peter Holemans - am 07.08.2017 09:55

Re: WebDev 22 - url subdomain -> WebDev.

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.

von Aad Gouka - am 07.08.2017 10:26

Re: WebDev 22 - url subdomain -> WebDev.

Ping Peter Holemans.

von Aad Gouka - am 08.08.2017 16:16

Re: WebDev 22 - url subdomain -> WebDev.

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("REQUEST_URI"),2,"="))


Cheers,

Peter Holemans

von Peter Holemans - am 09.08.2017 07:28

Re: WebDev 22 - url subdomain -> WebDev.

Thanks Peter,

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

Best regards,

Aad

von Aad Gouka - am 09.08.2017 10:24
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

von Fabrice Harari - am 09.08.2017 12:11
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

von Aad Gouka - am 09.08.2017 12:22
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

von Fabrice Harari - am 09.08.2017 13:35
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

von Aad Gouka - am 10.08.2017 08:34
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

von Peter Holemans - am 10.08.2017 11:46
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

von Fabrice Harari - am 10.08.2017 13:43
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.

von Peter Holemans - am 10.08.2017 14:19
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

von Aad Gouka - am 10.08.2017 14:25
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.