views:

39

answers:

1

ASP.NET MVC helpers generates URLs with slash, I use <base /> tag for my project, so it possible to place application to folder. Is it possible to generate relative URLs without first slash?

Thanks!

+1  A: 

Use this syntax for your images...

<img src="<%=ResolveUrl("~/Content/images/mylogo.jpg")%>"/>

...and all of your URLs will be calculated based upon the root of the domain, making them work in any page.

belugabob
The `<base />` tag is one, but this I need to do for each and every link, which is a pain, tweaking helpers is less pain :)
artvolk
Yes, I can relate to your pain. Theoretically, you could do <img runat="server" src="~/Content/images/mylogo.jpg"/> but if used in a loop, this only seems to work for the first iteration - the remainder produce <img/>. I spent a fair amount of time trying to sort this out, a while back - seems like it's time for a revisit.
belugabob