Can I use parent paths in Classic ASP?

One question I get often from developers who are working with classic asp is if they can use the parent path ( ../ ) in their scripts to include files from a higher level directory. That is okay in some host environments. However, many secure hosting companies, including ourselves, have ASP parent paths disabled by default.

Why Parent Paths Are Disabled?

“Disabling parent paths” is primarily a security feature. If you allow ../ in classic asp your site will be vulnerable to directory traversal. Simply put this could allow scripts to read files outside of the web directory that they are supposed to be running in which could lead to exposure or misuse of sensitive data.

The server is configured to prevent these security problems by not allowing the ASP scripts to accept parent paths.

So any code that depends on statements like:

<!--#include file="../config.asp"-->

doesn't work properly.

What if you try to use them?

If you are using parent paths in your Classic ASP application and they are disabled you might see errors like missing includes, broken pages or unexpected run time problems. What this usually means is that the server does not allow you to resolve a relative path outside of the directory structure you are allowed to use.

Proposed fix: Virtual Routes

You should be using virtual paths not parents paths. Virtual Paths specify where the files are located in the root of the web site. This gives you a more secure and reliable architecture.

Instead of for example:

<!--#include file="../includes/header.asp"-->

You should use:

<!--#include file="/includes/header.asp"-->

This way you don’t have to depend on the directory levels and your code will be a lot easier to maintain especially if you are working on a bigger project and your files might move or get restructured over time.

Benefits of Virtual Paths

Conclusion

Parent paths may be useful but should not be enabled in a secure hosting environment. Virtual paths are nice to have your Classic ASP application more modern, hosting friendly, stable and secure. If you’re updating older projects to take advantage of performance and security improvements, updating your include paths is an important step.