views:

29

answers:

2

I'm working on an multi tenant app, so I have a lot of dynamic subdomains:

user1.example.com user2.example.com

etc

It works great, but there's one problem though. Images are not displayed.

<img src="/images/logo.png" />

Will display on example.com, but it won't work on user1.example.com

I can of course use the following solution:

<img src="http://example.com/images/logo.png" />

But I want to have something more elegant if that's possible.

+3  A: 

If the images are common, why don't you host them on a sperate subdomain such as static.example.com. This will help performance too as the images will be cached if people use applications on multiple subdomains. Putting other static content there, such as common javascript files, will aid performance too.

You can also create a custom HTML Helper to output the static URL for the image.

starskythehutch
Yeah I came across that a lot. If I'm not mistaken, PayPal for example hosts images on images.paypal.com. But it means that I'd have to put this extra "http://images.example" instead of just "/images"... Well, I can just use Find -> Replace :)
Alex
Why not make an HTML helper rather than putting in the actual link? Will make it easy to swap out in the future.
starskythehutch
That's a good suggestion. Thanks.
Alex
A: 

Have you tried using something like: <img src="<%=Url.Content("~/")%>images/logo.png" />

CubanX