帮助ASP.Net错误:“无法使用前导..退出顶级目录”(ASP.Net error: “Cannot use a leading .. to exit above the top directory

编程入门 行业动态 更新时间:2024-10-10 05:22:52
帮助ASP.Net错误:“无法使用前导..退出顶级目录”(ASP.Net error: “Cannot use a leading .. to exit above the top directory”)

我在我的生产网站上每小时看到这个错误几次,我不太确定如何修复它。 我已经使用了源代码,我没有在代码中的任何地方使用“../”来生成路径。

我的应用程序在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.

最满意答案

这可能是由于使用“〜/ 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.

更多推荐

本文发布于:2023-08-06 10:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1447631.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:前导   错误   目录   Net   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!