Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using IIS virtual directories in Visual Studio Web Application projects

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?

like image 890
kenwarner Avatar asked Dec 22 '09 03:12

kenwarner


People also ask

What is the difference between virtual directory and application in IIS?

Virtual directories and applications are now separate objects, and they exist in a hierarchical relationship in the IIS configuration schema. Briefly, a site contains one or more applications, an application contains one or more virtual directories, and a virtual directory maps to a physical directory on a computer.

How do I create a virtual directory in Visual Studio?

The virtual directory is created automatically when you run your project. Is that not working for you? You can close the ticket. VS will automatically create virtual directory for you if you append a directory name to url like https://localhost:5677/mywebapp.


1 Answers

A virtual directory contained within a web application in IIS simply looks like a package in Visual Studio.

By opening the root app and clicking 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 breaks 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 either in Visual Studio.

However if you make the virtual directories into applications in IIS and 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 :)

like image 177
War Avatar answered Oct 11 '22 20:10

War