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

[英]Using IIS virtual directories in Visual Studio Web Application projects


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

\ads
\photos

我有一个ASP.NET项目,其中包含以下目录\ 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

这两个文件夹中都有数以千计的文件,这些文件经常更新。我目前的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

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?

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

6 个解决方案

#1


2  

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

IIS中的Web应用程序中包含的虚拟目录看起来就像是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.

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

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.

首先在IIS中查找您想要的方式,然后在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.

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

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.

如果在IIS上设置2个网站并将物理文件夹映射到两个虚拟目录上的图像,则在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.

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

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

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

Hope it helps :)

希望能帮助到你 :)

#2


0  

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.

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

#3


0  

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.

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

#4


0  

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

另一种选择......如果你正在使用SVN,如果你很高兴在磁盘上物理两次,但仍然让它们同步,那就是使用SVN Externals

#5


0  

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.

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

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.

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

#6


0  

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.

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

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

以下是其工作原理的基础链接。

http://dotnetperls.com/ashx-handler

http://dotnetperls.com/ashx-handler


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2009/12/22/df58fc0282dfbca3e2049af8841edc9d.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号