简体   繁体   English

无法将.net 3.5网站添加到IIS Express

[英]Unable to Add .net 3.5 Website to IIS Express

So, my issue is that I have a fairly large ASP.NET 3.5 project that I am trying to run locally using an IIS Express installation. 所以,我的问题是我有一个相当大的ASP.NET 3.5项目,我试图使用IIS Express安装在本地运行。 I am one of many developers on my team who run this and other projects using IIS Express, and I actually run a .NET 4.0 site (complete with local SSL) on a daily basis with no issues. 我是团队中使用IIS Express运行此项目和其他项目的众多开发人员之一,我实际上每天运行.NET 4.0站点(使用本地SSL),没有任何问题。 For reference, my machine runs Windows 7 Ultimate 64-bit with Microsoft Visual Studio 2010, and I am the administrator on the local machine. 作为参考,我的机器运行Windows 7 Ultimate 64位与Microsoft Visual Studio 2010,我是本地机器的管理员。 Visual Studio runs with administrative rights, and I have made sure that all of the App Pools listed in inetmgr are running. Visual Studio以管理权限运行,我确保inetmgr中列出的所有应用程序池都在运行。

Here's the workflow that I get when attempting to run the project locally: 这是我尝试在本地运行项目时获得的工作流程:

  • When I run my project for the first time, or if I remove any sites listed in Microsoft WebMatrix (the config utility for IIS Express, similar to inetmgr), I get this sequence of messages: 当我第一次运行我的项目时,或者如果我删除Microsoft WebMatrix中列出的任何站点(IIS Express的配置实用程序,类似于inetmgr),我得到以下消息序列:

(1) A Yes-No dialog from Microsoft Visual Studio that states, (1)Microsoft Visual Studio的“是 - 否”对话框指出,

The local IIS URL http://localhost:2000/site/path/ specified for Web project My.Web.Project has not been configured. In order to open this project the virtual directory needs to be configured. Would you like to create the virtual directory now?

(2) At this point, I click "Yes". (2)此时,我点击“是”。 An intermediate window from VS pops up with a loading bar, gets to about 50%, and then a Warning dialog from VS pops up, reading: 一个VS的中间窗口弹出一个加载栏,大约50%,然后弹出一个来自VS的警告对话框,阅读:

Configuring Web http://localhost:2000/ for ASP.NET 3.5 failed. You must manually configure this site for ASP.NET 3.5 in order for the site to run correctly. Visual Studio cannot detect whether this virtual root has been configured for use with ASP.NET 2.0 The likely cause is that you do not have sufficient privileges to access the IIS metabase. You may need to manually configure this site for ASP.NET 2.0 in order for your site to run correctly.

(3) At this point I can only click "Ok" or "Help, so I click OK to continue. It proceeds to do this same process for any other projects in my solution that are configured to run in IIS Express locally. (3)此时我只能单击“确定”或“帮助”,所以我单击“确定”继续。它继续为我的解决方案中配置为在本地IIS Express中运行的任何其他项目执行相同的过程。

  • When I attempt to run the site locally by hitting CTRL-F5, I get an error dialog box that reads, Unable to launch the IIS Express Web Server 当我尝试通过按CTRL-F5本地运行该站点时,出现一个错误对话框,显示Unable to launch the IIS Express Web Server
  • When I attempt to view details about said site in Microsoft Web Matrix, I get an error message from WebMatrix that reads: An error caused WebMatrix to shut down. Error message: Invalid application pool name 当我尝试在Microsoft Web Matrix中查看有关所述站点的详细信息时,我收到来自WebMatrix的错误消息,其中显示: An error caused WebMatrix to shut down. Error message: Invalid application pool name An error caused WebMatrix to shut down. Error message: Invalid application pool name
  • This error message is correct, except when I look at the IIS Express configuration file (C:\\%User Dir%\\My Documents\\IISExpress\\config\\applicationhost.config), in the <sites> section, each application has an <application> tag with only a path attribute specified, no applicationPool attribute specified. 此错误消息是正确的,除非我查看IIS Express配置文件(C:\\%User Dir%\\ My Documents \\ IISExpress \\ config \\ applicationhost.config),在<sites>部分中,每个应用程序都有一个<application>标记仅指定了path属性,未指定applicationPool属性。 (Conversely, the 4.0 app that does work on IISExpress has this attribute specified). (相反,在IISExpress上运行的4.0应用程序指定了此属性)。
  • Once I add an applicationPool attribute to a site, I can open/see/edit its details in WebMatrix, but still am unable to run it locally. 一旦我将applicationPool属性添加到站点,我就可以在WebMatrix中打开/查看/编辑其详细信息,但仍然无法在本地运行它。

So, what am I doing wrong or what configuration is incorrect on my machine that is stopping me from running, but not any other developers with the same code? 那么,我的错误是什么,或者我的机器上哪些配置不正确阻止我运行,而不是任何其他具有相同代码的开发人员?

For an application, if the appPool is not specificed explicitly default apppool would be used. 对于应用程序,如果未明确指定appPool,则将使用默认的apppool。 In IIS Express default app pool is Clr4IntegratedAppPool 在IIS Express中,默认应用程序池是Clr4IntegratedAppPool

<applicationDefaults applicationPool="Clr4IntegratedAppPool" /> . <applicationDefaults applicationPool="Clr4IntegratedAppPool" />

If your application is not a .net 4.0 app, then set it accordingly. 如果您的应用程序不是.net 4.0应用程序,请相应地进行设置。 If your application is 2.0 app, then set the appPool to 'Clr2IntegratedAppPool'. 如果您的应用程序是2.0应用程序,则将appPool设置为“Clr2IntegratedAppPool”。

Below given are application pools pre-defined in IIS Express configuration. 下面给出了IIS Express配置中预定义的应用程序池。

Clr4IntegratedAppPool
Clr4ClassicAppPool
Clr2IntegratedAppPool
Clr2ClassicAppPool

I ran into this in VS 2017, on a machine without IIS installed. 我在VS 2017中,在未安装IIS的计算机上遇到此问题。 So finding the application pool setting is harder. 因此,找到应用程序池设置更难。

I had tried rolling a site back to .NET Framework 2.0. 我曾尝试将网站滚动回.NET Framework 2.0。 More work than it's worth, so abandoned that branch and went back to my previous git branch which used 4.6.1. 更多的工作,而不是它的价值,所以放弃了那个分支,然后回到我之前使用4.6.1的git分支。 However IIS Express kept trying to run as 2.0! 但是IIS Express一直试图以2.0运行!

Finally found where it's set. 终于找到了它的位置。 It's under the solution folder: .vs\\config\\applicationhost.config 它位于解决方案文件夹下:.vs \\ config \\ applicationhost.config

Then found my site ("CBR_Report"), and the setting: applicationPool="Clr2IntegratedAppPool". 然后找到我的站点(“CBR_Report”)和设置:applicationPool =“Clr2IntegratedAppPool”。

<sites>
        <site name="WebSite1" id="1" serverAutoStart="true">
            <application path="/">
                <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation=":8080:localhost" />
            </bindings>
        </site>
        <site name="CBR_Report" id="2">
            <application path="/" applicationPool="Clr2IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="C:\Code\Cost_Based_Rate\CBR_Report" />
            </application>

So, I actually solved this as I was finishing writing the question. 所以,当我写完这个问题时,我实际上解决了这个问题。 As I was ascertaining the details for the configuration file, I realized that the way the project is setup, there are two applications defined in the first site in the config (one is a service that provides data retrieval, the other is a full-fledged website), and so I was only providing the missing applicationPool attribute for two of the three applications. 当我确定配置文件的细节时,我意识到项目的设置方式,在配置的第一个站点中定义了两个应用程序(一个是提供数据检索的服务,另一个是完整的网站),所以我只为三个应用程序中的两个提供了缺少的applicationPool属性。

If I can figure out why it was missing the required appPool attributes, I'll update this answer. 如果我能弄清楚为什么它缺少所需的appPool属性,我会更新这个答案。 Hopefully this helps someone else, too! 希望这也有助于其他人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM