Another topic on "Cannot use a leading .. to exit above the top directory"

W

webonomic

A number of topics ask how to solve the "Cannot use a leading .. to
exit above the top directory" error.

I am having the same problem with an asp.net 2.0 website. The site
works fine on Localhost, but not when I move the site to my hosting
company.

I've read that turning the Parent Paths option to ON in the IIS
properties should do the trick. It is ON for both my localhost and my
online host. Only the localhost still works.

I've switched hardcoded links from "../app/mypage.aspx" where ../
(brings you to the Root directory) to "/app/mypage.aspx" thinking that
the ".." is what is causing the problem.

The site implements a Masterpage in the root directory.

Maybe this is some kind of permissions thing?

Please please help!
 
W

webonomic

After some careful fiddling around for a couple hours, I figured out
what the problem was. First of all, note that Parent Paths has nothing
to do with the issue. They can be on or off.

If your head section has the runat server (<head runat="server">), and
you are using Masterpages, and aren't or are using Themes but still
have a <link href="../styles/styles.css" rel="stylesheet" /> in your
Head section, because the Head section is process at the server, it
will add at least one but could be more " ../ ".

If you use themes, take out the <link href....>. Using themes will
automatically link any CSS in your Theme directory and will link with
the proper

The ../ is also added to some other HTML elements like the FAVICON
link.

For stylesheets, you can still use
<style type="text/css">
@import "../styles/layout.css";
</style>
Asp.net will not add a ../ to that.

You can also do this:
<script type="text/javascript">
//<![CDATA[
document.write('<link rel="Stylesheet" type="text/css" href="<%=
Page.ResolveUrl("~/styles/styles.css") %>" />');
and it will work. This was posted on
http://www.telerik.com/Default.aspx?PageId=2202&b311D=orJO1
and was what made me realize that the extra ../ get's added to elements
when you have the runat server in the Head.

Please note that you cannot simply use HTML comments (<!-- -->) to
comment out any hardcoded <link rel=stylesheet> elements. So what I
mean is, you cannot go
<!-- <link href="../styles/styles.css" rel="stylesheet" /> -->
You MUST use Asp.Net comment code:
<%= <link href="../styles/styles.css" rel="stylesheet" /> -->

As far as I can, after hours of searching, this is THE solution.



- your us
If you have this problem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top