Thursday, September 11, 2008

ERROR: Disallowed Parent Path in ASP page

What happen?
When you open up an ASP page and you get an error:

Active Server Pages error 'ASP 0131'
Disallowed Parent Path
The Include file '../<filename.ext>' cannot contain '..' to indicate the parent directory./<path>/<filename.ext>, line <number>

What's the problem?
If you use relative paths in include statements or when inserting images with Microsoft Active Server Pages (ASP), you will get an error when you browse that page.

This is because by default ASP's "parents paths" for a Web site or application are disabled.

The Solution:
The best solution found from http://support.microsoft.com/kb/226474 is to use the absolute virtual paths from the root of the website instead of the relative paths (...).

Example:
<!--#include virtual="/<virtual path>/<filename.ext>"--> instead of
&lt;!--#include virtual="/<virtual path>/<filename.ext>"-->

Alternative method will be to enable the parent paths, but this is not the preffered method as stated in Microsoft's website. (Refer to their More Information section for details)

As there's too many relative paths used in my apps, I'll just use the second solution.
Steps below are used (for Internet Information Services 7.0):

  1. Start Internet Services Manager.
  2. Click Default Web Site, and then click Properties.
  3. Double-click ASP in the Features pane.
  4. Expand Behavior.
  5. Click Enable Parent Paths.
  6. Click True for Enable Parent Paths.
  7. Click Apply.
Done!