Tuesday 5 August 2008

HTTP Server Variable Gotcha

If you need to get the URL of the referring page that has submitted a form you need to look at the server variable "HTTP-REFERER" not "HTTP-REFERRER". It appears that a spelling mistake early on in the web has stuck.

I have been programming a web page using ASP which submitted a form, processed the details and redirected to a confirmation page. However, the form could be submitted from two different sites (an intranet site and a corresponding interent site) but both sites had to submit to the same site (it was updating an MS Access database). So I was looking at the referring page to determine which site to redirect back to. Doing some research had suggested getting the value of Request.ServerVariables("HTTP-REFERRER"), however after some time trying to figure out why it wasn't working I found out that it should be Request.ServerVariables("HTTP-REFERER").