views:

287

answers:

3

I using urlrewriter.net to implement friendly urls. When I did the rewriting I used subfolders on occasions.

I found myself having problems with images and links and the ~ sign wasn't working for me. After reading a bit I found out that I'm not the only one with that problem and they recommended using full path "www.website.com/images/x.jpg" etc. Now, I can't develop and QA because all of the links go to my real online website.

What can I do?

+1  A: 

If the URL prefix is your only concern, have you thought about adding a key to your web.config for the URL prefix and then dynamically generate the path to your images that way?

By doing this you can easily migrate all the code up to production when finished, and then simply update the web.config to point everything to the proper server.

Dillie-O
A: 

~ only works with ASP.NET Web Controls, not standard HTML controls.

A similar problem is when you have content pages (located in subfolders) referencing a masterpage in the application root. You need to use Image and Hyperlink controls in the MasterPage since the files are referenced from the location of the content page.

<asp:Image ID="Image1" runat="server" ImageUrl="~/images/Test.png" AlternateText="" />

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

Gordon Bell
A: 

Dillie-O: what do i do with the client side images? how do i use a generic prefix there?