Disabling image path rebasing

  • Thread starter Thread starter DamienS
  • Start date Start date
D

DamienS

Hi,

I'm wondering if there's a way to prevent ASP.Net from rebasing the
URLs/Paths in my Images.

My website is using a reasonably complex system to perform skinning
(custom code combined with out of the box ASP themes). The problem is
that whenever I add an image (either Image or HtmlImage), ASP is
overwriting my URL with it's version. I need the URL to be fixed to
http://mysite/images/xyz.jpg.

I've managed to get it going by using a literal control, however I'd
rather use server side controls because of their other benefits.

Thanks very much in advance,


Damien
 
Could you show an example how it transforms your constant URL ?
there are several methods like ResloveURL or ResolveClientUrl have u
tried these kind of methods and see if something cold be helpful?
 
Hi,

Thanks for that.

The issue was to do with the 'rebasing' of images when using Master
pages (Lookup "URL Rebasing In Master Pages" in http://www.odetocode.com/Articles/419.aspx).

Your article helped alot though in that I used it to just create a
'fully formed' URL. It appears that rebasing only occurs when the URL
passed to a control is 'relative'.

If you're interested, the code I ended up with was

_images.ToList().ForEach(x =>
{
// Need to pass the fully formed URL to prevent
rebasing.
string URL =
Request.Url.AbsoluteUri.Replace(Request.FilePath, "/tempfiles/") +
x.ThumbanailFileName(false);
Image i = new Image() { ImageUrl = URL };
this.ph1.Controls.Add(i);
});


Thanks very much for your help.



Damien
 
Back
Top