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

N

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.
 
L

lisa

Nathan said:
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
 
N

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.
 
M

Mythran

Nathan Sokalski said:
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
 
N

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.
 
S

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 :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top