ASP.NET 2.0 and the UrlRewriter issue

by Dimi 18. August 2008 00:23

Those of you who work with the Intelligencia UrlRewrite module may have encountered the following bug:

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

I faced a similar problem and couldn't find any solution to fix this. In fact it seems most approaches head to the wrong direction. Here is a short list of what you should take care of

Replace the .. in links with ~/ so the following line

   1: <asp:HyperLink ID="HyperLink1" NavigateUrl="../MyTest.aspx" runat="server" />

should be replaced using:

   1: <asp:HyperLink ID="HyperLink1" NavigateUrl="~/MyTest.aspx" runat="server" />

Avoid placing Images in the asp:HyperLink Control. If you want the following:

   1: <asp:HyperLink ID="HyperLink1" NavigateUrl="http://www.dgrigoriadis.net" ImageUrl="~/Images/bild1.jpg" runat="server" />

just rewrite the code to:

   1: <asp:HyperLink ID="HyperLink2" NavigateUrl="http://www.dgrigoriadis.net" runat="server">
   2:     <asp:Image ID="Image1" ImageUrl="~/Images/bild1.jpg" runat="server" />
   3: </asp:HyperLink>

While I was trying to find a solution on the web I realized that most solutions didn't work for me and/or went a way which didn't even had to do with the actual problem. So I took the time to split down the entire page where the error occured and finally noticed that in my case the second solution above was the cause of the error message. I had a DataList on my site which retrieved the Image url from the database and a link to another site and so I put a HyperLink control on the ItemTemplate and filled the ImageUrl property. After rewriting that part with the solution above everything went right.

Sometimes big problems are resolved using the most easy way ;)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

web development

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen