views:

920

answers:

6

I have an ASP.NET project that has the following directories

\ads
\photos

both these folders have thousands of files in them that get updated frequently. I currently have my IIS set up like

\inetpub\wwwroot\foo
\inetpub\wwwroot\foo\ads
\inetpub\wwwroot\foo\photos
\inetpub\wwwroot\foo.staging
\inetpub\wwwroot\foo.staging\ads
\inetpub\wwwroot\foo.staging\photos

I am considering turning this into

\inetpub\wwwroot\foo
\inetpub\wwwroot\foo\ads
\inetpub\wwwroot\foo\photos
\inetpub\wwwroot\foo.staging
\inetpub\wwwroot\foo.staging\ads
\inetpub\wwwroot\foo.staging\photos
\inetpub\wwwroot\foo.resources\ads
\inetpub\wwwroot\foo.resources\photos

and turning the subdirectories in foo and foo.staging into virtual directories that point to the foo.resources subdirectories. This way while I'm testing in staging, I don't have to copy all the files in ads and photos every time I deploy and worry about things being out of sync. is this a bad idea? I'm developing in Visual Studio 2008 - Is there a way to get VS to treat my web application project subdirectories as virtual directories?

A: 

I think the way to go about this is to set it up the way you want it in IIS first with your vdirs, then open the website from IIS in Visual Studio. See my answer to this question.

PhilPursglove
thanks, i saw that as well. that works for Web Sites but not Web Applications
qntmfred
+1  A: 

A virtual directory contained within a web application in iis simply looks likea package in vs.

by opening the root app and clicing on the package it should ask you if you want to add the child app / vdir to the solution then open it as a second project, you can then refer to it or consume it as needed.

The idea behind test and live deployments is that you should have separate data in case your testing breks something essentially by using the live data for testing you have to be sure that you wont delete / alter something you shouldn't or you will break your live copy of the data.

Having said that if all you plan to build is something that reads the data, this is a great idea as it will save you a lot of disc space and time on deployments.

Get it looking the way you want it in IIS first then open things up in VS.

Visual Studio treats all Virtual applications defined on the server as a sub application. If the resources are not setup in the child directories as an application in IIS it should appear as a normal folder.

For example ...

If you setup 2 websites on IIS and map the physical folder to your images on both as virtual directories you should have access to them as normal folders when you open eitherin visual studio.

However if you make the virtual directories in to applications in IIS then open the website in VS it should just show a package, clicking on that adds it as a second project in VS.

I'm not the best at explaining things but hopefully that made sense.

Hope it helps :)

Wardy
A: 

..Just thinking outside the box

I have a similar problem with my application with regaring to having loads of resources to copy up on deployment. I'm considering building a file handler that serves up image resources to the browser. I.e. When linking to images you'd having something like /filehandler.ashx?image=/ads/101/o3904838402384.jpg then you can have just have a config setting that points to different or the same filestorage folders for both Test and Live enviroments.

Perhapes a bit overakill, but like I said just thinking outside the box :)

Here is a link to the fundametals of how it works.

http://dotnetperls.com/ashx-handler

Mantisimo
A: 

You could, use linked folders in Visual Studio = this creates a virtual link to a folder in another project (or somewhere else on disc), but doesn't physically copy them on disk.

Paul
Paul, have you tried this?
John Saunders
For small things yes, I haven't experimented with anything particularly complicated, but this is what it was made for (afaik)
Paul
A: 

Another option...If you're using SVN and if you're happy to have the images physically twice on disk, but still have them in sync, is to use SVN Externals

Paul
Paul, you should have edited your original answer instead of adding a new one.
John Saunders
But they're different answers...
Paul
A: 

Since these are resources, is there any particular reason you need them to be in Visual Studio at all? VS, IMO, is for managing code in a solution, not necessarily directory structure.

In IIS, you can set your directory structure up exactly like you have it (or even have the virtual directory point to a network drive), and Visual Studio can completely ignore it, since it's likely just a bunch of static files.

Jordan
Jordan, it's nice to be able to see the images when using Design view, and Visual Studio can verify whether or not your URLs are valid, but only if the images actually exist on disk.
John Saunders