如何配置IIS Express调试子目录中的应用程序? [英] How to configure IIS Express to debug an application in a subdirectory?

查看:64
本文介绍了如何配置IIS Express调试子目录中的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Web应用程序通常位于IIS根目录的子目录中.假设子目录是"app"

My web application is typically located in a subdirectory of the root in IIS. Suppose the subdirectory is "app"

当我尝试在Visual Studio中调试它时,该路径始终以localhost为根,没有子目录.这弄乱了我在应用程序中的路径.

When I try to debug it in Visual Studio, the path is always rooted at localhost, with no subdirectory. This messes up my paths in the application.

当我尝试将项目URL的形式从 http://localhost:port/更改为 http://localhost:port/app 时,它只是说无法创建虚拟目录."好吧,这就是它第一次说的,直到我从application.config文件中删除了该应用程序条目,然后它成功了.

When I try to change the project URL's form from http://localhost:port/ to http://localhost:port/app it just says "Cannot create virtual directory." Well, that's what it said the first time, until I removed the application entry from the application.config file, then it succeeded.

当我尝试将替代应用程序根URL"应用于同一事物时,它根本不起作用.它或者收到错误500.0 Internal Server错误,或者在某些情况下,它的行为就像是将应用程序的web.config文件同时应用于根目录和虚拟子目录,因为它给出了错误,我正在尝试添加具有以下内容的模块:已经添加(大概在根目录中).

When I try the "override application root URL" to the same thing, it just doesn't work. It either gets an Error 500.0 Internal Server error, or in some cases it acts like it's applying the application's web.config file to both the root and the virtual subdirectory, because it gives an error that I'm trying to add a module that has already been added (presumably in the root).

我曾尝试在IIS Express的application.config中编辑项目的设置,但似乎没有任何设置组合.

I've tried editing the project's settings in application.config for IIS Express, but no combination of settings seems to work.

当我知道该项目已部署到IIS的子目录中时,我不明白为什么Visual Studio将该项目放在IIS Express根目录中.我认为默认情况下,它应该与目录结构匹配.

I don't understand why visual studio is situating the project at an IIS Express root directory, when it knows this project is deployed to IIS in a subdirectory. I think it should match the directory structure by default.

这是现在的样子:

<site name="app" id="5">
   <application path="/" applicationPool="Clr4IntegratedAppPool">
     <virtualDirectory path="/app" physicalPath="C:\Users\username\Desktop\wwwroot\app" />
   </application>
   <bindings>
     <binding protocol="http" bindingInformation="*:3056:localhost" />
   </bindings>
</site>

如果我将应用程序路径更改为"/app",那么它将给出错误500.19,表示配置无效.如果我做同样的事情并删除虚拟目录标签,那么它将无法完全启动IIS Express.

If I change the application path to "/app", then it gives error 500.19, saying the configuration is invalid. If I do the same thing and remove the virtual directory tag, then it fails to launch IIS Express altogether.

推荐答案

我在这里找到了答案: https://stackoverflow.com/a/4733387/88409 问题不同,但答案相同.

I found the answer here: https://stackoverflow.com/a/4733387/88409 Different question, but same answer.

基本上,必须创建一个子应用程序,而不仅仅是一个子虚拟目录.

Basically, one must create a child application, not just a child virtual directory.

<site name="app" id="5">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Users\username\Desktop\wwwroot" />
    </application>
    <application path="/app" applicationPool="Clr4IntegratedAppPool">
      <virtualDirectory path="/" physicalPath="C:\Users\username\Desktop\wwwroot\app" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:3056:localhost" />
    </bindings>
</site>

它似乎需要两个应用程序条目(即,它需要一个根应用程序(即使它实际上是一个空的虚拟目录)以及子应用程序).如果我在根目录上省略了第一个应用程序条目,那么它将收到错误500.19无法访问请求的页面,因为该页面的相关配置数据无效."但是,使用这两个应用程序条目,它都可以正常工作.

It seems to require both application entries (i.e. it requires a root application (even if it's physically an empty dummy directory) as well as the child application). If I omit the first application entry at the root, then it gets error 500.19 "The requested page cannot be accessed because the related configuration data for the page is invalid." With both application entries, however, it works without any issues.

据我所知,在Visual Studio中无法产生上述设置,因此必须在application.config中手动对其进行编辑.因此,这些设置与Web应用程序项目文件本身完全无关,IMO,这是不好的.

As far as I can tell, there is no way to produce the above settings in Visual Studio, so it must be edited manually in application.config. These settings are therefore completely disassociated with the web application project files themselves, which isn't good, IMO.

这篇关于如何配置IIS Express调试子目录中的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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