Web: how to detect the complete web address?

Hi Folks,

I would like to detect the complete address the user typed in the browser, to use different part of the webapp.
for example
https://sales.mycompany.com/orders
and detect it in the websession ? or the app event ?
from https://sales.mycompany.com/sales or https://sales.mycompany.com/invoices

where do I put the code needed to detect this ?

thanks.

Try doing this Inside WebApp.HandleURL:

' get the full URL as requested from the client...

' first, make headers into a dictionary for easier debugging
var headers() as string = request.headerNames
var d as new Dictionary
for each key as string in headers
  d.value(key) = request.Header(key)
next

' next, get the parts needed to recreate the URL
var theHost as string = d.value("host")
var path as string = request.path
var query as string = request.QueryString
var secure as Boolean = request.Secure

' make the URL
var fullURL as string = _
If(secure,"https://", "http://")  _
+ theHost _
+ If(path="", "", "/" + path) _
+ If(query="", "", "?" + query)


Edit: bug fix

3 Likes

so what I need it the path value in your code ?

Sorry, I don’t understand. Path is a property of WebRequest, see WebRequest — Xojo documentation

Take a look at this posting, it might be helpful :grinning:
It shouldn’t be this difficult - Open a Xojo page from HandleURL - Targets / Web - Xojo Programming Forum

1 Like

In. @Mike_D s code, don’t forget to add this after thehost

+ if(app.port <> 80, ":" + app.port.toString, "") _

If you’re using ssl, change Port to SecurePort

2 Likes

Actually, Greg’s code is not necessary and would break mine.

Turns out that the “Host” header includes the port # already, as shown here:

image

2 Likes