ASP.Net 错误:“无法使用前导 .. 退出顶级目录”

发布于 2024-07-06 12:38:29 字数 338 浏览 4 评论 0原文

我在生产站点上每小时会多次看到此错误,但不太确定如何修复它。 我已经 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

嘴硬脾气大 2024-07-13 12:38:29

这可能是由于在超链接控件上使用了“~/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.

无语# 2024-07-13 12:38:29

只需在您网站的 ASP 设置中将“启用父路径”设置为“True”

即可解决我的问题

Just set the Enable Parent Paths to True in the ASP settings from your website

That solved the problem for me

_畞蕅 2024-07-13 12:38:29

使用反射器深入研究 URLRewriter.Net 代码。

Use reflector to dig into the URLRewriter.Net code.

静谧幽蓝 2024-07-13 12:38:29

我会再次给你的重写路径一次,看看是否有一个路径包含一个不存在、已被破坏或实际上位于 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?

不可一世的女人 2024-07-13 12:38:29

您确定是您造成了错误吗? 某些脚本(红色代码/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?

江湖正好 2024-07-13 12:38:29

我通过安装 .NET 3.5 SP1 解决了这个问题。

I was able to resolve this issue by installing .NET 3.5 SP1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文