Saturday, March 31, 2012

Sharing one /images folder between 3 apps?

I've got three applicatinos that need to share the same graphics files. I wanted to do this:

wwwroot/
images/
app1/
<img src="http://pics.10026.com/?src=/images/foo.gif">
app2
app3

...but that doesn't seem to work. How can I access the /images directory from all three apps?I guess you could create a separate Virtual directory which you then access through a fullyqualified URL in all your other applications:

<img src="http://pics.10026.com/?src=http://myGraphicsApp/images/foo.gif">">

I think you have got at least 2 options, with one of them listed above already.

The second would be to have you folder structure similar to this:

[ : web
[ : images ]
[ : site1 ]
[ : site2 ]
[ : site3 ]
]
Then create an ASP.NET page that returns all image requests by simply taking in the image name and going to "../images/whateverimagename" then returning it, if it finds it. This could be wasteful, especially if you get decent traffic.

Unfortunately, simply referencing the folder within the HTML does no good because the web browser makes a separate request for the image(s) as it parses through the HTML it gets.

So, assuming your website is "http://www.mysite.com" then it would get this image request: "http://www.mysite.com/images/foo.gif"

Also since it is on the browser, sending ../images/foo.gif would not work either because "http://www.mysite.com/../images/foo.gif" does not exist as far as it knows.

0 comments:

Post a Comment