10

我有一个 ASP.NET 项目,其中包含以下目录

\ads
\photos

这两个文件夹中都有数千个文件,这些文件经常更新。我目前的 IIS 设置为

\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
\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

并将 foo 和 foo.staging 中的子目录转换为指向 foo.resources 子目录的虚拟目录。这样,当我在 staging 中进行测试时,我不必在每次部署时都复制广告和照片中的所有文件并担心事情不同步。这是一个坏主意吗?我正在 Visual Studio 2008 中开发 - 有没有办法让 VS 将我的 Web 应用程序项目子目录视为虚拟目录?

4

6 回答 6

2

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 :)

于 2010-05-17T15:58:04.807 回答
0

我在我的应用程序中看到了类似的问题,即在部署时要复制大量资源。
我正在考虑构建一个文件处理程序,为浏览器提供图像资源。即当链接到图像时,您将拥有类似的东西,/filehandler.ashx?image=/ads/101/o3904838402384.jpg您可以只拥有一个配置设置,该设置指向测试和实时环境的不同或相同的文件存储文件夹。

这是它工作原理的链接。

http://dotnetperls.com/ashx-handler

于 2010-06-04T10:14:36.250 回答
0

可以在 Visual Studio 中使用链接文件夹 = 这会创建到另一个项目(或磁盘上的其他位置)中的文件夹的虚拟链接,但不会将它们物理复制到磁盘上。

于 2010-06-09T11:45:48.387 回答
0

另一种选择...如果您使用的是 SVN,并且您很高兴将图像物理两次在磁盘上,但仍然保持同步,则使用 SVN Externals

于 2010-06-09T11:46:58.557 回答
0

我认为解决这个问题的方法是首先使用 vdir 在 IIS 中设置它,然后在 Visual Studio 中从 IIS 打开网站。请参阅这个问题的回答。

于 2009-12-22T07:56:12.867 回答
0

由于这些是资源,有什么特别的原因需要它们在 Visual Studio 中吗?VS,IMO,用于管理解决方案中的代码,不一定是目录结构。

在 IIS 中,您可以完全按照自己的方式设置目录结构(甚至让虚拟目录指向网络驱动器),Visual Studio 可以完全忽略它,因为它可能只是一堆静态文件。

于 2010-06-22T01:48:56.510 回答