views:

20

answers:

1

If I use routing with 2 query parameters, like this:

System.Web.Routing.RouteTable.Routes.MapPageRoute("HomeRoute", "home/{f1}/{f2}", "~/Home.aspx");

My image does not appear on my Home.aspx page:

<img src="~/img/img.jpg" /> or <img src="img/img.jpg" />

But it does appear when I access the http://localhost:3760/Website/Home.aspx URL

I tried using Routing.Ignore with no luck. I look for a solution wich should work for an unlimited number of subfolders: "home/{f1}/{f2}/.../{fn}"

The problem is raised by ASP.NET routing module. The image will show if I type <img src="../../img.jpg" /> but this goes further to <img src="../../../img.jpg" /> if I have "home/{f1}/{f2}/{f3}" on the routing rule

+1  A: 

Well i can see that <img src="~/img/img.jpg" /> is wrong it should be <img src="<%=Page.ResolveClientUrl(~/img/img.jpg)%>" />

This is because ~ is an asp symbol, not a html symbol.

Unfortunately i do not know if this is your actual problem

Andrey
yes, you are right, thank you. Isn't there another simpler solution ? I don't want to type ResolveClientUrl on every image that I use
pixel3cs
you can look at what Page.ResolveClientUrl resolves to in your html page and use that url. Personally i prefer the asp bit. If your site structure changes this can save a lot of time
Andrey