Knowledgebase

Home » Item #360

Disallowed path characters error - include files not allowed to reference parent directories

Item: #360
Date: 8 Jan 2003
Applies to
v4

Question

I get the following error on all pages:

Server.MapPath() error 'ASP 0175 : 80004005'
Disallowed Path Characters

The '..' characters are not allowed in the Path parameter for the MapPath method.


Why is this and what is the solution?

Answer

The problem is with the references to include files in CactuShop. It also affects the DSN-less connection which also references a file in a parent folder.

The database issue can generally be overcome by using a DSN connection but there is no easy work-round for the include file issue.

CactuShop uses 'include' files to contain code that is used in several places, for example:

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

This includes our common functions (code for handling routine tasks like running database queries) on each page so they can be used on any page.

However, some hosting companies disable the ability to include files that are in directories above the folder where the main page file resides. There is a potential threat that code in include files could be run by other web sites on the same machine.

Even include files in folders at the same level cannot be used if the host stops parent paths, because the path to a level folder goes up one folder (i.e. to the parent folder) and then back down.

The best solution to this is to ask the hosting company to enable pages to allow include files in parent folders (directories).

Alternatively, you could modify the CactuShop pages to use virtual include paths rather than relative file paths. Assuming you were running CactuShop on the route of your web, you'd then replace all occurrences of this:

#include file="../includes/

with this:

#include virtual="/includes/

There are many search/replace utilities available for free on the web that can go through the whole of CactuShop and make this change easily.

Note that the virtual path will need to be adjusted if you run CactuShop in a folder on your site.

Also, you will need to find and replace other occurences of "../" with "/".

Can't find the answer you need? Click here to open a support ticket.

« Back