Home All Groups Group Topic Archive Search About

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

Author
30 May 2005 7:54 PM
Nathan Sokalski
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
njsokal***@hotmail.com
http://www.nathansokalski.com/

Author
31 May 2005 11:45 AM
lisa
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
Author
31 May 2005 9:21 PM
Nathan Sokalski
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
njsokal***@hotmail.com
http://www.nathansokalski.com/

<l***@starways.net> wrote in message
Show quoteHide quote
news:1117539945.601412.186620@z14g2000cwz.googlegroups.com...
> 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
>
Author
1 Jun 2005 9:10 PM
Mythran
Show quote Hide quote
"Nathan Sokalski" <njsokal***@hotmail.com> wrote in message
news:%233C$vaiZFHA.3328@TK2MSFTNGP09.phx.gbl...
>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
Author
1 Jun 2005 10:46 PM
Nathan Sokalski
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
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"Mythran" <kip_potter@hotmail.comREMOVETRAIL> wrote in message
news:edeMh5uZFHA.2996@TK2MSFTNGP10.phx.gbl...
>
> "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message
> news:%233C$vaiZFHA.3328@TK2MSFTNGP09.phx.gbl...
>>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
>
Author
6 Jun 2005 3:41 PM
Sergey Polyakov
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


Show quoteHide quote
"Nathan Sokalski" <njsokal***@hotmail.com> wrote in message
news:uu3nPvvZFHA.3096@TK2MSFTNGP15.phx.gbl...
> 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
> njsokal***@hotmail.com
> http://www.nathansokalski.com/
>
> "Mythran" <kip_potter@hotmail.comREMOVETRAIL> wrote in message
> news:edeMh5uZFHA.2996@TK2MSFTNGP10.phx.gbl...
>>
>> "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message
>> news:%233C$vaiZFHA.3328@TK2MSFTNGP09.phx.gbl...
>>>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
>>
>
>