Click here to Skip to main content
Click here to Skip to main content
Go to top

Utility to convert file includes to virtual includes

, 4 Nov 2007
Rate this:
Please Sign up or sign in to vote.
A utility to convert file includes to virtual includes.

Screenshot - ConvertFile2Virtual.jpg

Introduction

Today I had to move an ASP application I developed some years ago to a new hosting provider. After uploading all the files, I discovered that the application had an error in the includes.

Active Server Pages, ASP 0131
Disallowed Parent Path

This error is caused by a configuration in IIS that many hosting providers use, that disallows includes of type file with relative paths to a parent folder, like this: <#include file="../../path_to_include">. The only solution is to replace all those includes with virtual includes with absolute paths such as: <#include virtual="/path_to_include">. This is a very annoying process because basically you have to edit by hand each individual file and include, because the absolute path depends on the including page's path and the included page's path. If you have a web application with hundreds of files, like I did, this is not an option. A full description of the error is available here.

So I developed a mini-utility to do this for me. You give it a start folder which should be your app's root folder, and it searches for all .asp files, replacing the file="" relative paths with virtual="" absolute paths.

Using the code

It is written as a console app in C# .NET 2.0. To run it, just copy it somewhere, open a command line, and execute:

ConvertFile2Virtual.exe path

where path is the path to your root path, such as "c:\projects\client website\". Please note that the path is surrounded by double quotes because the path contains spaces and it ends with a trailing backslash.

I hope this can be useful to someone else.

History

  • v1.0 - Initial release.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Bruno Gazzera
Web Developer
Unknown
No Biography provided

Comments and Discussions

 
GeneralIIS 6 and IIS 7 default settings for 'Parent paths' Pinmemberdeeps000012-Nov-07 21:12 
AnswerRe: IIS 6 and IIS 7 default settings for 'Parent paths' PinmemberBruno Gazzera21-Nov-07 10:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 4 Nov 2007
Article Copyright 2007 by Bruno Gazzera
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid