在 Visual Studio Web 应用程序项目中使用 IIS 虚拟目录

发布于 2024-08-15 05:11:21 字数 814 浏览 6 评论 0原文

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

\广告
\照片

这两个文件夹中都有数千个经常更新的文件。我目前的 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 子目录的虚拟目录。这样,当我在分阶段进行测试时,我不必每次部署时都复制广告和照片中的所有文件,也不必担心事情不同步。这是一个坏主意吗?我正在 Visual Studio 2008 中进行开发 - 有没有办法让 VS 将我的 Web 应用程序项目子目录视为虚拟目录?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

ヤ经典坏疍 2024-08-22 05:11:21

IIS 中的 Web 应用程序中包含的虚拟目录看起来就像 Visual Studio 中的包。

通过打开根应用程序并单击包,它应该询问您是否要将子应用程序/vdir 添加到解决方案。然后将其作为第二个项目打开,然后您可以根据需要引用它或使用它。

测试和实时部署背后的想法是,您应该拥有单独的数据,以防测试出现问题。本质上,通过使用实时数据进行测试,您必须确保不会删除/更改不应该删除/更改的内容,否则将破坏数据的实时副本。

话虽如此,如果您计划构建的只是读取数据的东西,那么这是一个好主意,因为它将为您节省大量磁盘空间和部署时间。

首先在 IIS 中按照您想要的方式显示它,然后在 VS 中打开它。

Visual Studio 将服务器上定义的所有虚拟应用程序视为子应用程序。
如果资源没有作为 IIS 中的应用程序设置在子目录中,则它应该显示为普通文件夹。

例如...

如果您在 IIS 上设置 2 个网站,并将物理文件夹作为虚拟目录映射到两个网站上的图像,则当您在 Visual Studio 中打开其中一个网站时,您应该可以像普通文件夹一样访问它们。

但是,如果您将虚拟目录放入 IIS 中的应用程序,然后在 VS 中打开该网站,它应该只显示一个包。单击它将其添加为 VS 中的第二个项目。

我不擅长解释事情,但希望这是有道理的。

希望它有帮助:)

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

吖咩 2024-08-22 05:11:21

我认为解决此问题的方法是首先使用虚拟目录在 IIS 中按照您想要的方式进行设置,然后在 Visual Studio 中从 IIS 打开网站。请参阅我对这个问题

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.

才能让你更想念 2024-08-22 05:11:21

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

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.

不再见 2024-08-22 05:11:21

另一种选择...如果您使用 SVN 并且您很高兴在磁盘上物理上存储两次图像,但仍然保持同步,那么可以使用 SVN 外部

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

别闹i 2024-08-22 05:11:21

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

在 IIS 中,您可以像实际情况一样设置目录结构(甚至让虚拟目录指向网络驱动器),而 Visual Studio 可以完全忽略它,因为它可能只是一堆静态文件。

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.

一抹苦笑 2024-08-22 05:11:21

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

这是其工作原理的基本原理的链接。

http://dotnetperls.com/ashx-handler

I see a similar problem with my application with regarding 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 environments.

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

http://dotnetperls.com/ashx-handler

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文