I've just discovered a bug/issue when using redirected pages. Let's assume I have the following in a page (Animal.aspx)
<asp:Image id="i1" runat="server" ImageUrl="~/Images/foo.jpg" />
In web.config I have:
<urlMappings enabled="true">
<add url="~/Animals/Dog.aspx"
mappedUrl="~/Animal.aspx?Animal=Dog" />
</urlMappings>
Run the page and the image doesn't show, because the ImageURL is incorrectly rebased.
The solution is to do the rebasing yourself; there's a whole thread on about ASP.NET Paths on
Rick Strahl's Blog; there's a nice FixupUrl() method in the comments.
Alternatively you can use the
VirtualPathUtility:
i1.ImageUrl = VirtualPathUtility.ToAbsolute("~/Images/foo.jpg");