Cannot use a leading .. to exit above the top directory - HttpException (0x80004005)

Posted on 2007-10-17
Last Modified: 2010-06-24
Hello experts!
I have an project for which I created 2 different virtual directories at IIS. One is used by the debug version of the project and other is used by the production version of the project.
The problem is that I'm getting an error when "navigating" thru the physical directories of each project.
On the debug version I'm using (..) to navigate to the previous directory, but I can't use (~) to proceed.
On the production version I'm using (~) to navigate to the previous directory, but I can't use (..).
Is it something I need to configure at IIS?

This is the error message:

[HttpException (0x80004005): Can't use .. on the left to go to the superior directory.]   System.Web.Util.UrlPath.ReduceVirtualPath(String path) +3644954   System.Web.Util.UrlPath.Reduce
(String path) +84   System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative) +355   System.Web.Configuration.AuthenticationConfig.GetCompleteLoginUrl(HttpContext context, String loginUrl) +211
   System.Web.Configuration.AuthenticationConfig.AccessingLoginPage(HttpContext context, String loginUrl) +48   System.Web.Security.FormsAuthenticationModule.OnEnter(Object source, EventArgs eventArgs) +167  
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
Question by:andrepires
    LVL 96

    Accepted Solution

    '~' is the root marker, not the previous page marker.  Why can't you use it in both production and development environments?

    LVL 16

    Assisted Solution

    the ~ character on IIS and the VS Dev server will give you the root of the application, are you trying to link to files outside of the application root by using ..?
    LVL 2

    Author Comment

    I'm just trying to link to some files that are inside of some different directories of my application, but all directories are inside the root directory.
    I'm not talking about pages here, but directories.
    So, suppose I have the following directory structure:
    Now suppose that I want to link to a file that is located at the root dir and that I'm currently inside MySubFolder2.
    On the production app I can use ~ to go directly to the root directory, but cannot use ../../MyFile.xml to refer to the file on the root dir.
    On the debug version I can use ../../MyFile.xml to refer to the file on the root dir, but cannot use ~
    LVL 16

    Expert Comment

    ok, that is odd, how are you running the debug version?
    LVL 2

    Author Comment

    I'm using VS to run the project.
    LVL 16

    Expert Comment

    I have run the following code from a [webroot]\NewFolder1\NewFolder2 from both VS and IIS all seams fine: -

        <asp:HyperLink ID= "HyperLink2" runat="server" NavigateUrl="~/XMLFile.xml">with Tilda</asp:HyperLink>
        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="../../XMLFile.xml">with Dots</asp:HyperLink>

    Does your code differ from the above?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Introduction (All good things must come to an end ( The original MySQL API ( has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all curre…
    Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now