From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
|This event is only available for Web applications.|
This event fires when an http request comes to your app which would otherwise result in a 404 Page Missing response.
To call a web service implemented using HandlSpecialURL you would use an address similar to this:
The above address is to a standalone web app running on the local machine. In this method, Request.Path contains "GetAllCustomers".
To override the HTTP 404 error response, use Request.Print to output the data you wish to send, set the Request.Status to the HTTP status code you wish to return and return True.
If you are building a standalone web app, you will need to check Request.Path to see if it is empty. An empty string means that a browser has connected to the root level of your app.
Response.Status = 200 // An HTTP Response code of 200 means everything is OK
You can use this to essentially serve data from just about any URL that you want. There are a few exceptions for things that are reserved and will not call this event:
- /framework - This is for framework files
- /xojo - for future development
- _ (anything that starts with an underscore at the top level)
- Session URLs - these are the hex encoded session IDs which start with /B156D2E6338304E2AAD151DC5680F50E
- /api and /special - URLs which would have gone to WebApplication.HandleSpecialURL. This is so existing apps continue to work as expected.
Indexing for Google
With the HandleURL method, you can now create pages that Google can index. You return valid HTML for Google, including links for "Next" and "Previous" pages.
Return a custom 404 page:
If Request.Path <> "" Then
// First, create the HTML answer
Response.Write "Oops! You took a wrong turn. "
Response.Write "Please put it in reverse and try again."
// 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.
Response.Status = 200
// You MUST return True if you want to override the output.