title: Debugging ASP.NET Cannot use a leading .. to exit above the top directory
body: <p>I'm getting the dreaded <code>Cannot use a leading .. to exit above the top directory.</code></p>
  
  <p>Unfortunately for me it's being generated...somewhere?....out of my control. Are there tools that will help me find out where it's being generated? Or even the actual text of the hyperlink? Maybe intellitrace somehow?</p>
  
  <p>Yes, there's a million google results for it. I know what I need to fix, I just have no idea where the problem is actually occurring.</p>
  
  <p>I tried overriding the render event, and then calling ResolveClientURL on every single HtmlLink object I could find by walking the control tree from the base, but that never throws an exception or does anything wrong. Could it be dying only during <code>base.render</code> because I'm calling ResolveClientURL from a page in <code>/v5/plugins/dashboard</code> and the base page is in <code>/v5/</code>?</p>
  
  <p>Here's the bit I wrote to debug manually. I would expect this code to throw an exception.</p>
  
  <pre><code>  protected override void Render(HtmlTextWriter writer)
    {
      foreach (Control c in base.Controls)
      {
        Trace.Write("New base control");
        var baseParent = c;// findBaseParent(c);
        Trace.Write(baseParent.GetType().ToString());
        renderChillunsRecursive(baseParent, 0);
      }
      base.Render(writer);
    }
    private int total;
    private void renderChillunsRecursive(Control c,int depth)
    {
      var chilluns = c.Controls;
      foreach (Control a in chilluns)
      {
        renderChillunsRecursive(a,depth +1);
        total++;
      }
      string otherString = String.Empty;
      if(c.GetType() == typeof(HtmlLink))
      {
        HtmlLink theLInk = ((HtmlLink) c);
            otherString = theLInk.Href;
        otherString += " - " + theLInk.ResolveClientUrl(theLInk.Href);
      }
      Trace.Write(String.Format("{0} - {1} - {2} - {3} - {4}",depth,total,c.GetType(),c.ToString(),otherString));
    }
  </code></pre>
  
  <p>Stack Trace</p>
  
  <pre><code>[HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.]
     System.Web.Util.UrlPath.ReduceVirtualPath(String path) +8886247
     System.Web.Util.UrlPath.Reduce(String path) +52
     System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative) +214
     System.Web.UI.Control.ResolveClientUrl(String relativeUrl) +180
     System.Web.UI.HtmlControls.HtmlLink.RenderAttributes(HtmlTextWriter writer) +74
     System.Web.UI.HtmlControls.HtmlLink.Render(HtmlTextWriter writer) +42
     System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
     System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8703574
     System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
     System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
     System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
     System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer) +17
     System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
     System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
     System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8703574
     System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
     System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
     System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
     System.Web.UI.Control.Render(HtmlTextWriter writer) +10
     System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
     System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8703574
     System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
     System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
     System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
     System.Web.UI.Page.Render(HtmlTextWriter writer) +29
     FileBasePage.Render(HtmlTextWriter writer) +2331
     FileDetails.Render(HtmlTextWriter writer) in c:\inetpub\V5 - Development\Plugins\Dashboard\FileDetails.aspx.cs:690
     System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
     System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +8703574
     System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
  </code></pre>