Using virtual directories for common directories (scripts, images, styles, etc.)

  • Thread starter Jeffry van de Vuurst
  • Start date
J

Jeffry van de Vuurst

Hi,

(sorry for the crosspost, I wasn't sure which was the best place to
put this).

I was just thinking about something and wondered if any of you has
some ideas about this.

I'm using the NetAdvantage component suite from Infragistics for my
web applications. When installing they create several virtual
directories for the scripts and images directories that their
components use. That way e.g., when you drop a control on a form, and
the imagedirectory property is by default set to /ig_images/ it
automatically finds the images, no matter where the webform is located
in the hierarchy of the website.

I find this a clever idea. I've never done this and never seen a
website that does this, but it sounds like a good idea.

I mean, I have a web application with several subdirectories, user
controls, script/style/images directories etc. etc. It seems like a
good idea to turn my images, scripts, styles directories into virtual
directories, so that I can access them from anywhere within my web
application with simply the virtual directory name, not having to
worry anymore about those relative paths (../../).

I know about the "~" to access the virtual root, but I've had some
problems with that, especially when the web application is not in a
virtual directory but in its own website.

To make it short, it seems like all advantages, but are there any
disadvantages?

Thanks,
Jeffry
 
J

Jerry III

Virtual directory only means that the directory doesn't physically reside
under the application's directory. Your server side code could care less
whether a directory is virtual or not. So no, it's not a clever idea as a
virtual directory /style is referenced exactly the same way as real
directory /style.

What kind of problems did you have using ~/path? Remember that you need to
call ResolveUrl("~/path") in places where that's not called automatically...

Jerry
 
J

Jeffry van de Vuurst

Hmmm, you've got a point there. I guess I was a bit confused because I'm
used to developing my sites in virtual directories inside my Default Web
Site. That way you always have to work from the virtual root and you cannot
simply say /style, but you'd have to say /website1/style or something like
that.

Now that I'm using separate IIS websites for every site, I simply can use
/style.

I didn't know about ResolveUrl(), I'll take a look at that.

Thanks for your information.

Regards,
Jeffry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top