devxlogo

Create a Link to the Previous Page Using ASP

With pages that are generated dynamically, you can’t provide a hardcoded link back to the previous page. However, ASP often provides you with the name of the page that contained the jump to the current page. With Request.ServerVariables(“HTTP_REFERER”) you can create the link on the fly. Keep in mind that you may not always get a value for the referrer page. Protect yourself by checking for an empty string before displaying the link text. This code shows one way of displaying the Back link if the information is available.

 <%@ Language=VBScript %><%if Request.ServerVariables("HTTP_REFERER") <>"" then%>">Back<%end if%>

Notice that the “REFERER” part of the parameter is misspelled. In fact, you must misspell it to make the function work.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Seven Service Boundary Mistakes That Create Technical Debt

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.