ASP.Net 错误:“无法使用前导 .. 退出顶级目录”
我在生产站点上每小时会多次看到此错误,但不太确定如何修复它。 我已经 grep 了源代码,并且没有在代码中的任何位置使用“../”来生成路径。
我的应用程序在Win2003 Server 上的IIS6 上运行。 它使用 URLRewriter.Net 来允许网站拥有友好的 URL,我想知道这是否会导致问题。
我已经在谷歌上搜索了解决方案,并找到了几种可能性,但没有一个对我有用。
我尝试创建一个新的 App_Browser 文件来强制标记编写器设置使用特定的 HtmlTextWriter,正如最流行的解决方案之一所建议的那样,但这对我来说不起作用。 我还没有看到任何其他可能的解决方案。
I'm seeing this error several times an hour on my production site and am not quite sure how to fix it. I've grepped the source code and I am not using "../" anywhere in my code to generate a path.
My application is running on IIS6 on Win2003 Server. It's using URLRewriter.Net to allow the site to have friendly URLs, and I'm wondering if this could be contributing to the problem.
I've already Googled for a solution and have found several possibilities but none have worked for me.
I've tried creating a new App_Browser file to force the tagwriter settings to use a specific HtmlTextWriter, as suggested in one of the most popular solutions, but that hasn't worked for me. I haven't seen any other likely solutions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这可能是由于在超链接控件上使用了“~/something”。 当物理文件与友好 URL 位于不同的目录级别时,ASP.NET 在其生成的相对 URL 中使用过多的 ../,从而出现此错误。 如果您不能只使用绝对 URL,我相信您可以使用 Page.ResolveUrl("~/foo/bar") 来获取正确的相对 URL。
It's probably due to using "~/something", probably on a Hyperlink control. When the physical file is at a different directory level from the friendly URL, ASP.NET uses too many ../'s in the relative URL that it generates, giving this error. If you can't just use an absolute URL instead, I believe that you can use Page.ResolveUrl("~/foo/bar") to get the proper relative URL.
只需在您网站的 ASP 设置中将“启用父路径”设置为“True”
即可解决我的问题
Just set the Enable Parent Paths to True in the ASP settings from your website
That solved the problem for me
使用反射器深入研究 URLRewriter.Net 代码。
Use reflector to dig into the URLRewriter.Net code.
我会再次给你的重写路径一次,看看是否有一个路径包含一个不存在、已被破坏或实际上位于 Web 应用程序之外的文件夹。 你能在这里发布重写规则吗?
I would give your rewrite paths another once through and see if maybe there is a path that contains a folder that either doesn't exist, has been flubbed or is in fact outside the web application. Can you post the rewrite rule here?
您确定是您造成了错误吗? 某些脚本(红色代码/Nimda)会在互联网上搜寻类似该错误的 URL 遍历。
这是内部的还是外部的? 您的机器有可能被扫描吗?
Are you sure that you are causing the error?. Some scripts (Code Red/Nimda) troll the internet looking for a URL traversal that looks like that error.
Is this internal or external? Is it possible that your machine is getting scanned?
我通过安装 .NET 3.5 SP1 解决了这个问题。
I was able to resolve this issue by installing .NET 3.5 SP1.