Another topic on "Cannot use a leading .. to exit above the top directory"

Discussion in 'ASP .Net' started by webonomic, Jan 18, 2006.

  1. webonomic

    webonomic Guest

    A number of topics ask how to solve the "Cannot use a leading .. to
    exit above the top directory" error.

    I am having the same problem with an asp.net 2.0 website. The site
    works fine on Localhost, but not when I move the site to my hosting
    company.

    I've read that turning the Parent Paths option to ON in the IIS
    properties should do the trick. It is ON for both my localhost and my
    online host. Only the localhost still works.

    I've switched hardcoded links from "../app/mypage.aspx" where ../
    (brings you to the Root directory) to "/app/mypage.aspx" thinking that
    the ".." is what is causing the problem.

    The site implements a Masterpage in the root directory.

    Maybe this is some kind of permissions thing?

    Please please help!
    webonomic, Jan 18, 2006
    #1
    1. Advertising

  2. webonomic

    webonomic Guest

    After some careful fiddling around for a couple hours, I figured out
    what the problem was. First of all, note that Parent Paths has nothing
    to do with the issue. They can be on or off.

    If your head section has the runat server (<head runat="server">), and
    you are using Masterpages, and aren't or are using Themes but still
    have a <link href="../styles/styles.css" rel="stylesheet" /> in your
    Head section, because the Head section is process at the server, it
    will add at least one but could be more " ../ ".

    If you use themes, take out the <link href....>. Using themes will
    automatically link any CSS in your Theme directory and will link with
    the proper

    The ../ is also added to some other HTML elements like the FAVICON
    link.

    For stylesheets, you can still use
    <style type="text/css">
    @import "../styles/layout.css";
    </style>
    Asp.net will not add a ../ to that.

    You can also do this:
    <script type="text/javascript">
    //<![CDATA[
    document.write('<link rel="Stylesheet" type="text/css" href="<%=
    Page.ResolveUrl("~/styles/styles.css") %>" />');
    and it will work. This was posted on
    http://www.telerik.com/Default.aspx?PageId=2202&b311D=orJO1
    and was what made me realize that the extra ../ get's added to elements
    when you have the runat server in the Head.

    Please note that you cannot simply use HTML comments (<!-- -->) to
    comment out any hardcoded <link rel=stylesheet> elements. So what I
    mean is, you cannot go
    <!-- <link href="../styles/styles.css" rel="stylesheet" /> -->
    You MUST use Asp.Net comment code:
    <%= <link href="../styles/styles.css" rel="stylesheet" /> -->

    As far as I can, after hours of searching, this is THE solution.



    - your us
    If you have this problem


    webonomic wrote:
    > A number of topics ask how to solve the "Cannot use a leading .. to
    > exit above the top directory" error.
    >
    > I am having the same problem with an asp.net 2.0 website. The site
    > works fine on Localhost, but not when I move the site to my hosting
    > company.
    >
    > I've read that turning the Parent Paths option to ON in the IIS
    > properties should do the trick. It is ON for both my localhost and my
    > online host. Only the localhost still works.
    >
    > I've switched hardcoded links from "../app/mypage.aspx" where ../
    > (brings you to the Root directory) to "/app/mypage.aspx" thinking that
    > the ".." is what is causing the problem.
    >
    > The site implements a Masterpage in the root directory.
    >
    > Maybe this is some kind of permissions thing?
    >
    > Please please help!
    webonomic, Jan 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom
    Replies:
    1
    Views:
    3,735
    Ken Schaefer
    Dec 11, 2003
  2. Simon Harris
    Replies:
    2
    Views:
    25,831
    Juan T. Llibre
    May 8, 2005
  3. Nathan Sokalski
    Replies:
    5
    Views:
    3,503
    Sergey Polyakov
    Jun 6, 2005
  4. moondaddy
    Replies:
    2
    Views:
    3,962
    =?Utf-8?B?VEJERVY=?=
    Jan 12, 2006
  5. Nathan Sokalski

    Error: Cannot use a leading .. to exit above the top directory.

    Nathan Sokalski, May 30, 2005, in forum: ASP .Net Building Controls
    Replies:
    5
    Views:
    234
    Sergey Polyakov
    Jun 6, 2005
Loading...

Share This Page