Cannot use a leading ../ to exit above the top directory

前端 未结 10 800
小蘑菇
小蘑菇 2020-11-30 08:37

I have a asp.net web site with it we have admin area with login page for admin only and all site is allowed for all - i need to ask how to define the right security configur

相关标签:
10条回答
  • 2020-11-30 08:50

    I moved my project from "standard" hosting to Azure and get the same error when I try to open page with url-rewrite. I.e. rule is :

    <add key="/iPod-eBook-Creator.html" value="/Product/ProductDetail?PRODUCT_UID=IPOD_EBOOK_CREATOR" />
    

    try to open my_site/iPod-eBook-Creator.html and get this error (page my_site/Product/ProductDetail?PRODUCT_UID=IPOD_EBOOK_CREATOR can be opened without any problem).

    I checked the fully site - never used .. to "level up"

    0 讨论(0)
  • 2020-11-30 08:50

    I got same problem... and I did it.

    My code before:

    <link rel="stylesheet" href="../css/style.default.css" type="text/css" />
    

    And the problem solved after I changed my code into this:

    <link rel="stylesheet" href="css/style.default.css" type="text/css" />
    

    So I think "href=../" is not allowed, because I don't have problem when I use "../" in "src=../"

    0 讨论(0)
  • 2020-11-30 08:53

    What this means is that your web page is referring to content which is in the folder one level up from your page, but your page is already in the website's root folder, so the relative path is invalid. Judging by your exception message it looks like an image control is causing the problem.

    You must have something like:

    <asp:Image ImageUrl="..\foo.jpg" />
    

    But since the page itself is in the root folder of the website, it cannot refer to content one level up, which is what the leading ..\ is doing.

    0 讨论(0)
  • 2020-11-30 08:55

    I had such a problem and the answer, although frustrating to find, was solved by doing a search on the offending page for the ".." in the error message. I am using Visual Studio Express and the solution was changing "../../Images/" to "~/Images/" . Hopefully this will help someone.

    0 讨论(0)
  • In my case it turned out to be commented out HTML in a master page!

    Who knew that commented out HTML such as this were actually interpreted by ASP.NET!

    <!--
    <link rel="icon" href="../../favicon.ico">
    -->
    
    0 讨论(0)
  • 2020-11-30 08:56

    I had the problem occur on my system in a very strange way. In my system customers create products that sit inside a directory structure of product categories. So ProductA might sit in the folder CategoryInner inside the folder CategoryOuter. I had just added a feature where my URL would show the category nesting on the URL thusly:

    http://www.somedomain.com/product/CategoryOuter/CategoryInner/ProductA.aspx

    Obviously the nesting on the URL was just for SEO purposes (and to show the user what category their product was sitting in. But when I used ResolveClientUrl on some URLs that used to work, it must've been confused by the extra fake pathing. The error message was popping up in the debugger on some line that was never the problem so it took me quite some time to figure out what was going on. I wnet through and removed all of my ResolveClientUrl calls that acted on anything that didn't start with a ~ and made the rest of the paths absolute paths.

    0 讨论(0)
提交回复
热议问题