Development issues when using absolute path in links (due to friendly urls)

I am using urlrewriter.net to implement friendly urls. When I was doing the rewriting, I sometimes used subfolders.

I was having problems with images and links and the ~ sign didn't work for me. After reading a little, I found out that I am not the only one with this problem and they recommended using the full path "www.website.com/images/x.jpg" etc. Now I cannot develop and QA because all links go to my real online site.

What can I do?

0


source to share


2 answers


If URL prefix is ​​your only problem, have you considered adding a key to your web.config to prefix the URL and then dynamically generate the path to your images that way?



Through this, you can easily migrate all your code to production when finished and then just update the web.config to point everything to the appropriate server.

+1


source


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

A similar problem is that you have content pages (located in subfolders) that link to the master page at the root of the application. You need to use the Image and Hyperlink controls in the MasterPage as the files link to 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>

0


source







All Articles