Odd bug in ASP.Net with URL rewriting
I've just finished tearing my hair out, yes I no longer
have curly hair I am now bald, over a bug with SQLBits site.
I just uploaded a load of new changes to the main site. We have a beta site
to test things on before breaking the main one.
So I expected that the upload to the main site would be fine. It wasn't.
The URL rewriting we were using for the previous events was breaking the
site. With error "Cannot use a
leading .. to exit above the top directory. ".
I've had that before and the issue was referencing controls by absolute
rather than virtual path i.e. "..\controls\mycontrol.ascx" instead of
"~\controls\mycontrol.ascx". I checked all these and found a few but none on the
pages that were breaking.
It was breaking within ASP.Net and I couldn't find the control that was
causing the problem. So I stripped the page down and rebuilt it gradually, then
started using a master page again. Eventually I found the issue with a HyperLink
control.
I had the following
<
asp:HyperLink ID="TelerikLink"
runat="server" NavigateUrl="http:\\www.telerik.com" ImageUrl="~\images\sponsors\telerik_square.gif">
</asp:HyperLink>
Commenting it out and everything worked.
So I figured the only relative URL that is in there is the image but I had
other images on the master page. But using a seperate image control and so
change it to two controls i.e
<asp:HyperLink ID="TelerikLink"
runat="server" NavigateUrl="http:\\www.telerik.com">
<asp:Image ID="TelerikImage" runat="server"
ImageUrl="~\images\sponsors\telerik_square.gif"
ToolTip="Build with Telerik Asp.Net Components"
/>
</asp:HyperLink>
And heh presto it worked.
So if you are finding you are getting "Cannot use a leading .. to exit above
the top directory. ". then check to see if you are using HyperLinks with
the ImageUrl.
-