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

Discussion in 'ASP .Net' started by Nathan Sokalski, May 30, 2005.

  1. When running a page I am working on, I recieve the following error:

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

    I suspect this has something to do with the problem I posted in a recent
    posting "HyperLink.NavigateUrl always adds an extra ../ when going to a
    higher level directory" on Sunday, May 29, 2005 7:33 PM
    However, I cannot be sure because I cannot view the generated code since it
    gives the error before anything is shown, and the debug goes through all my
    code with no errors until the end of the Page.Load event (it makes it
    through all of the code I wrote). My Stack Trace is as follows:

    [HttpException (0x80004005): Cannot use a leading .. to exit above the top
    directory.]
    System.Web.Util.UrlPath.Reduce(String path) +701
    System.Web.Util.UrlPath.Combine(String basepath, String relative) +304
    System.Web.UI.Control.ResolveClientUrl(String relativeUrl)
    System.Web.UI.WebControls.HyperLink.AddAttributesToRender(HtmlTextWriter
    writer) +58
    System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
    writer) +17
    System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +17
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +131
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
    System.Web.UI.Control.Render(HtmlTextWriter writer) +7
    System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
    writer)
    System.Web.UI.WebControls.TableCell.RenderContents(HtmlTextWriter writer)
    System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +131
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
    System.Web.UI.Control.Render(HtmlTextWriter writer) +7
    System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter
    writer)
    System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +131
    System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer)
    System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +131
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
    System.Web.UI.Control.Render(HtmlTextWriter writer) +7
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +131
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
    System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
    +44
    System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +262
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +131
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
    System.Web.UI.Control.Render(HtmlTextWriter writer) +7
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +131
    System.Web.UI.Page.ProcessRequestMain() +1926

    What can I do about this? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, May 30, 2005
    #1
    1. Advertising

  2. Nathan Sokalski

    Guest

    Nathan Sokalski wrote:
    > When running a page I am working on, I recieve the following error:
    >
    > Cannot use a leading .. to exit above the top directory.
    >
    > I suspect this has something to do with the problem I posted in a recent
    > posting "HyperLink.NavigateUrl always adds an extra ../ when going to a
    > higher level directory" on Sunday, May 29, 2005 7:33 PM
    > However, I cannot be sure because I cannot view the generated code since it
    > gives the error before anything is shown, and the debug goes through all my
    > code with no errors until the end of the Page.Load event (it makes it
    > through all of the code I wrote). My Stack Trace is as follows:


    You could try putting a breakpoint on Page.Load and stepping through
    the method. Check in the Command Window to see what the value of that
    variable is. Worse comes to worse, you can add something like this:

    If YourVariable.BeginsWith("../") Then
    YourVariable = Substring(YourVariable, 4)
    End If

    Or maybe that should be three. I can never remember if Substring is 0
    based or 1 based.

    Lisa
     
    , May 31, 2005
    #2
    1. Advertising

  3. I have tried using the breakpoint on Page.Load method, and I do not get any
    errors in that event and all of the variables are what I expect and want
    them to be while stepping through the code. The extra ../ is not added until
    the A tag is generated (which means I cannot view the value of the href
    attribute through a property in the Page.Load event). Because all of the
    variables and properties are what I want and expect them to be during
    execution, your suggested technique of using the SubString() method would
    not work in all cases because of situations. For example, look at the
    following code:

    myanchor.NavigateUrl="comments.aspx"

    In this situation, "../" would never be removed from the beginning of the
    String because it is not there to remove, yet it would still be added during
    the generation of the href attribute. I was looking at the
    Control.ResolveUrl method, which sounded like it might be what I wanted, but
    it is a method of the Control class, and the code where I assign the
    NavigateUrl property is in a separate class I have written. Any ideas?
    Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    <> wrote in message
    news:...
    > Nathan Sokalski wrote:
    >> When running a page I am working on, I recieve the following error:
    >>
    >> Cannot use a leading .. to exit above the top directory.
    >>
    >> I suspect this has something to do with the problem I posted in a recent
    >> posting "HyperLink.NavigateUrl always adds an extra ../ when going to a
    >> higher level directory" on Sunday, May 29, 2005 7:33 PM
    >> However, I cannot be sure because I cannot view the generated code since
    >> it
    >> gives the error before anything is shown, and the debug goes through all
    >> my
    >> code with no errors until the end of the Page.Load event (it makes it
    >> through all of the code I wrote). My Stack Trace is as follows:

    >
    > You could try putting a breakpoint on Page.Load and stepping through
    > the method. Check in the Command Window to see what the value of that
    > variable is. Worse comes to worse, you can add something like this:
    >
    > If YourVariable.BeginsWith("../") Then
    > YourVariable = Substring(YourVariable, 4)
    > End If
    >
    > Or maybe that should be three. I can never remember if Substring is 0
    > based or 1 based.
    >
    > Lisa
    >
     
    Nathan Sokalski, May 31, 2005
    #3
  4. Nathan Sokalski

    Mythran Guest

    "Nathan Sokalski" <> wrote in message
    news:%233C$...
    >I have tried using the breakpoint on Page.Load method, and I do not get any
    >errors in that event and all of the variables are what I expect and want
    >them to be while stepping through the code. The extra ../ is not added
    >until the A tag is generated (which means I cannot view the value of the
    >href attribute through a property in the Page.Load event). Because all of
    >the variables and properties are what I want and expect them to be during
    >execution, your suggested technique of using the SubString() method would
    >not work in all cases because of situations. For example, look at the
    >following code:
    >
    > myanchor.NavigateUrl="comments.aspx"
    >
    > In this situation, "../" would never be removed from the beginning of the
    > String because it is not there to remove, yet it would still be added
    > during the generation of the href attribute. I was looking at the
    > Control.ResolveUrl method, which sounded like it might be what I wanted,
    > but it is a method of the Control class, and the code where I assign the
    > NavigateUrl property is in a separate class I have written. Any ideas?
    > Thanks.
    > --


    Could the problem posted below be the same problem you are having? Seems to
    me to be :)

    http://support.microsoft.com/default.aspx?scid=kb;en-us;Q226474

    Mythran
     
    Mythran, Jun 1, 2005
    #4
  5. It doesn't look like it, for several reasons. First of all, the article you
    mention is for ASP, not ASP.NET. Second, the error message is different (my
    error message is about going above the top directory, while the article you
    mention is about parent directories). And most important, the extra ../ in
    my error is generated without me being told about it. The ../ in the article
    is hard coded (the coder knows it is there, they type it as part of their
    code). I don't think that this is the same problem I am having.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Mythran" <> wrote in message
    news:...
    >
    > "Nathan Sokalski" <> wrote in message
    > news:%233C$...
    >>I have tried using the breakpoint on Page.Load method, and I do not get
    >>any errors in that event and all of the variables are what I expect and
    >>want them to be while stepping through the code. The extra ../ is not
    >>added until the A tag is generated (which means I cannot view the value of
    >>the href attribute through a property in the Page.Load event). Because all
    >>of the variables and properties are what I want and expect them to be
    >>during execution, your suggested technique of using the SubString() method
    >>would not work in all cases because of situations. For example, look at
    >>the following code:
    >>
    >> myanchor.NavigateUrl="comments.aspx"
    >>
    >> In this situation, "../" would never be removed from the beginning of the
    >> String because it is not there to remove, yet it would still be added
    >> during the generation of the href attribute. I was looking at the
    >> Control.ResolveUrl method, which sounded like it might be what I wanted,
    >> but it is a method of the Control class, and the code where I assign the
    >> NavigateUrl property is in a separate class I have written. Any ideas?
    >> Thanks.
    >> --

    >
    > Could the problem posted below be the same problem you are having? Seems
    > to me to be :)
    >
    > http://support.microsoft.com/default.aspx?scid=kb;en-us;Q226474
    >
    > Mythran
    >
     
    Nathan Sokalski, Jun 1, 2005
    #5
  6. Hi Nathan

    If I understand you correctly, you are creating a Hyperlink child control
    inside your own control. If so you can try to add the href attribute
    directly to the Hyperlink's Attributes collection instead of assigning its
    NavigateUrl property. The attribute value will be rendered directly as you
    specified it without any additional processing.

    If you are using a Hyperlink control directly on a page, you can try to use
    the MapPath method to resolve the url before assigning.

    May be this will help :)

    --
    Best regards,
    Sergey


    "Nathan Sokalski" <> wrote in message
    news:...
    > It doesn't look like it, for several reasons. First of all, the article
    > you mention is for ASP, not ASP.NET. Second, the error message is
    > different (my error message is about going above the top directory, while
    > the article you mention is about parent directories). And most important,
    > the extra ../ in my error is generated without me being told about it. The
    > ../ in the article is hard coded (the coder knows it is there, they type
    > it as part of their code). I don't think that this is the same problem I
    > am having.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    > "Mythran" <> wrote in message
    > news:...
    >>
    >> "Nathan Sokalski" <> wrote in message
    >> news:%233C$...
    >>>I have tried using the breakpoint on Page.Load method, and I do not get
    >>>any errors in that event and all of the variables are what I expect and
    >>>want them to be while stepping through the code. The extra ../ is not
    >>>added until the A tag is generated (which means I cannot view the value
    >>>of the href attribute through a property in the Page.Load event). Because
    >>>all of the variables and properties are what I want and expect them to be
    >>>during execution, your suggested technique of using the SubString()
    >>>method would not work in all cases because of situations. For example,
    >>>look at the following code:
    >>>
    >>> myanchor.NavigateUrl="comments.aspx"
    >>>
    >>> In this situation, "../" would never be removed from the beginning of
    >>> the String because it is not there to remove, yet it would still be
    >>> added during the generation of the href attribute. I was looking at the
    >>> Control.ResolveUrl method, which sounded like it might be what I wanted,
    >>> but it is a method of the Control class, and the code where I assign the
    >>> NavigateUrl property is in a separate class I have written. Any ideas?
    >>> Thanks.
    >>> --

    >>
    >> Could the problem posted below be the same problem you are having? Seems
    >> to me to be :)
    >>
    >> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q226474
    >>
    >> Mythran
    >>

    >
    >
     
    Sergey Polyakov, Jun 6, 2005
    #6
    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,780
    Ken Schaefer
    Dec 11, 2003
  2. Simon Harris
    Replies:
    2
    Views:
    25,933
    Juan T. Llibre
    May 8, 2005
  3. moondaddy
    Replies:
    2
    Views:
    4,038
    =?Utf-8?B?VEJERVY=?=
    Jan 12, 2006
  4. 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:
    261
    Sergey Polyakov
    Jun 6, 2005
  5. Nathan Sokalski

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

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

Share This Page