3

我越来越害怕了Cannot use a leading .. to exit above the top directory.

对我来说不幸的是它正在生成......在某个地方?....超出我的控制。是否有工具可以帮助我找出它是在哪里生成的?甚至是超链接的实际文本?也许以某种方式进行智能跟踪?

是的,有一百万个谷歌搜索结果。我知道我需要解决什么,我只是不知道问题实际发生在哪里。

我尝试覆盖渲染事件,然后在每个 HtmlLink 对象上调用 ResolveClientURL,方法是从基础遍历控制树,但这永远不会引发异常或做错任何事情。它会不会base.render因为我从一个页面调用 ResolveClientURL/v5/plugins/dashboard而基础页面在/v5/

这是我为手动调试而写的。我希望这段代码会引发异常。

  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));
  }

堆栈跟踪

[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
4

2 回答 2

1

从母版页和错误页中删除 ../ 并放置 ~/ 纠正错误-不能使用前导 .. 退出顶级目录。

于 2014-09-01T09:50:28.287 回答
0

没有人回答我的实际问题-

是否有工具可以帮助我找出它是在哪里生成的?甚至是超链接的实际文本?也许以某种方式进行智能跟踪?

但是我们发现 IIS dll 安全性在某种程度上阻碍了我们。该命令c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "file:////C:\inetpub\V5 - Development\*" FullTrust -exclusive on修复了我们的问题 - 它类似于右键单击 dll 并选择取消阻止。(我们对这个测试服务器的远程部署包括压缩站点并将其放到服务器上,因此 windows 对其应用了一些额外的安全措施)。请参阅http://blogs.msdn.com/b/narahari/archive/2010/06/03/system-security-securityexception-request-for-the-permission-of-type-system-web-aspnethostingpermission-system-version -2-0-0-0-culture-neutral-publickeytoken-b77a5c561934e089-failed.aspx了解更多信息。

我们认为是因为 IIS 不喜欢站点 bin 文件夹中的 DLL,所以它从 gac 中找到了一个有用的 DLL,此时 ReduceVirtualPath 失败了,因为它实际上不在网站目录附近。

于 2013-02-11T18:50:04.353 回答