HandleURL Problem

  1. 2 weeks ago

    Hi,

    Just having a small problem here, am I just missing something glaring obvious please?

    Posted the below code verbatim from the Xojo manual into my web application event App.HandleURL

    Running locally the code works fine as it should

    When uploaded to the Xojo Cloud and tested, it doesn't appear to work and I get the response below;

    Not Found
    The requested URL /TheSoilSearchers-Dev/test was not found on this server.

    Any ideas people?

    Code placed in App.HandleURL

    // Don't override an empty request, or a session won't start.
    If Request.Path <> "" Then
    // First, create the HTML answer
    Request.Print "<html><body>"
    Request.Print "Oops! You took a wrong turn. "
    Request.Print "Please put it in reverse and try again."
    Request.Print "</body></html>"

    // Set the status code. The default value is 404,
    // but if you leave it that way, some browsers
    // will show their own. A value of 200 will make
    // the browser show your text instead.
    Request.Status = 200

    // You MUST return True if you want to override the output.
    Return True
    End If

    You need to include the index.cgi part:

    /TheSoilSearchers-Dev/index.cgi/test
  2. Barney

    May 21 New Zealand

    Try sending it something to work with just for the sake of testing using the ? before your query string
    The requested URL /TheSoilSearchers-Dev/?test=true&somethingelse=false

    Dim S,T as string
    Dim U,i as Integer

    Dim RequestName, RequestValue as string
    Dim ParamDictionary as Dictionary = New Dictionary

    S = Request.QueryString
    U = CountFields(S,"&")
    For i = 1 to U
    T = NthField(S,"&",i)
    RequestName = NthField(T,"=",1)
    RequestValue = NthField(T,"=",2)
    ParamDictionary.value(RequestName) = RequestValue
    Next

    If ParamDictionary.HasKey("test") then
    S = ParamDictionary.Value("test")
    S = DecodeURLComponent(S)

    If S = "true" then
    Request.Print("This is the response you asked for ?")
    Request.Print(S)
    Return true
    End if
    End if

  3. Hi Barney,

    I'm not trying to pass any parameters to this event as per your example;
    "The requested URL /TheSoilSearchers-Dev/?test=true&somethingelse=false"

    The code in this event should create a custom response to a page not found result, so passing parameters in this case is a non-event.

    Regards

    Colin

  4. Greg O

    May 21 Xojo Inc Answer scout.galaxy.barn
    Edited 2 weeks ago

    You need to include the index.cgi part:

    /TheSoilSearchers-Dev/index.cgi/test
  5. Hi Greg,

    Perfect, working ok now.

    Many thanks for your help.

    Regards

    Colin

or Sign Up to reply!