在 IIS express 中创建虚拟目录 [英] Creating virtual directories in IIS express

查看:31
本文介绍了在 IIS express 中创建虚拟目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 IIS express 中创建虚拟目录?我知道 Cassini 无法做到这一点,如果不使用完整版的 IIS 也能做到这一点就好了.

Is there any way to create a virtual directory in IIS express? I know that Cassini can't do this and it would be nice to be able to do this without using a full version of IIS.

到目前为止,我可以像这样在 IIS express 中本地浏览到我的应用程序:

I've got it so far that I can browse to my application locally in IIS express like this:

http://localhost:1132/

我想要做的是创建一个名为OffSiteStuff"的虚拟目录,并将其指向我的 C 驱动器上的某个位置,例如c:offsitestuff",然后像这样浏览到该文件夹​​中的项目:

What I would like to do is create a virtual directory called "OffSiteStuff" and point it to some location on my C drive, like "c:offsitestuff" and then browse to items in that folder like this:

http://localhost:1132/OffSiteStuff/UserUploadedImage.jpg

我知道我可以用我网站中的一个文件夹来做到这一点,并且仍然使用 IIS Express,或者,就此而言,普通的旧 Cassini,但是这个文件夹将存储用户上传的图像,我真的不想拥有这些图像与应用程序文件混在一起.

I know I could do this with a folder within my site and still use IIS Express, or, for that matter plain old Cassini, but this folder will store images uploaded by users and I really don't want to have these images mixed up with application files.

另一个变大"的解决方案是,每次我想调试使用异地内容的功能时,都将站点部署到成熟的 Server 2008 IIS 7.5 实例上,但这也有点麻烦.

The other, "go big" solution is to deploy the site onto a full blown Server 2008 IIS 7.5 instance every time I want to debug the features that use offsite content, but that is a bit cumbersome too.

有什么办法可以在 <System.WebServer/> Web 配置元素中执行此操作?

Is there any way I can do this in the <System.WebServer /> Web config element?

推荐答案

IIS express 配置由 applicationhost.config 管理.
你可以在

IIS express configuration is managed by applicationhost.config.
You can find it in

Users<用户名>DocumentsIISExpressconfig 文件夹.

Users<username>DocumentsIISExpressconfig folder.

您可以在其中找到为每个 IIS Express 配置的站点保存一个部分的站点部分.

Inside you can find the sites section that hold a section for each IIS Express configured site.

像这样添加(或修改)站点部分:

Add (or modify) a site section like this:

<site name="WebSiteWithVirtualDirectory" id="20">
   <application path="/" applicationPool="Clr4IntegratedAppPool">
     <virtualDirectory path="/" physicalPath="c:	empwebsite1" />
   </application>
   <application path="/OffSiteStuff" applicationPool="Clr4IntegratedAppPool">
     <virtualDirectory path="/" physicalPath="d:	empSubFolderApp" />
   </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:1132:localhost" />
   </bindings>
</site>

实际上,您需要在站点中为每个虚拟目录添加一个新的应用程序标记.您可以获得很大的灵活性,因为您可以为虚拟目录设置不同的配置(例如不同的 .Net Framework 版本)

Practically you need to add a new application tag in your site for each virtual directory. You get a lot of flexibility because you can set different configuration for the virtual directory (for example a different .Net Framework version)

编辑感谢 Fevzi Apaydın 指出更优雅的解决方案.

EDIT Thanks to Fevzi Apaydın to point to a more elegant solution.

你可以通过在 Application 标签中添加一个或多个 virtualDirectory 标签来达到同样的效果:

You can achieve same result by adding one or more virtualDirectory tag to the Application tag:

<site name="WebSiteWithVirtualDirectory" id="20">
   <application path="/" applicationPool="Clr4IntegratedAppPool">
     <virtualDirectory path="/" physicalPath="c:	empwebsite1" />
     <virtualDirectory path="/OffSiteStuff" physicalPath="d:	empSubFolderApp" />
   </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:1132:localhost" />
   </bindings>
</site>

参考:

这篇关于在 IIS express 中创建虚拟目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆