在IIS中托管.net Core应用程序.无法加载配置.属性'processPath'是必需的 [英] Hosting a .net Core application in IIS. Could not load configuration. Attribute 'processPath' is required

查看:740
本文介绍了在IIS中托管.net Core应用程序.无法加载配置.属性'processPath'是必需的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在IIS中托管.net Core API. 当我在Visual Studio中运行它时,一切都可以正常工作.为了进行部署,我首先将项目发布到一个文件夹中,然后将内容复制到所需的位置,然后在IIS中创建一个应用程序.设置为使用与无托管代码"共同构成的应用程序池.

I'm trying to host a .net Core API in IIS. When I have it running in Visual Studio everything is working correctly. For deployment I first published the project to a folder, copied the contents to the desired location and created an application in IIS. It is set to use an application Pool thats cofigured with "No managed code".

当我尝试调用一个可用的端点(通过前端或手动)时,收到HTTP 500错误(内部服务器错误.您正在寻找的资源有问题,并且无法显示.)

When I try calling one of the available Endpoints (through the frontend or manually) I receive an http 500 Error (Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.)

我在服务器上找不到任何有意义的日志.我只有在事件查看器中才能找到错误事件.

I can't find any meaningful logs on the Server. Only in the Event Viewer could I find an Error event.

无法加载配置.异常消息:属性'processPath'是必需的."

"Could not load configuration. Exception message: Attribute 'processPath' is required."

现在我不确定为什么会这样,因为在项目的Web.config中肯定存在processPath属性,并且在发布时会这样生成.看起来像:

Now im not sure why this would be the case because the processPath attribute in the Web.config of the project is definitely present and is generated like this when publishing. It looks like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\MyApplication.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>

已安装核心Hosting Bundle.完全重启在此服务器上并不可行(或者至少我想避免这种情况).因此,我跑了

The core Hosting Bundle is installed. A complete restart isn't really viable on this server (or at least I want to avoid it). For that reason I ran

net stop was /y
net start w3svc

了解所做的任何更改.

我将很高兴就如何解决此问题提出任何想法和建议. 提前非常感谢!

I'll be happy about any ideas and advice on how to resolve this. Thanks a lot in advance!

推荐答案

因此,花了我比我承认的更长的时间来找到导致此问题的原因. 但是对于那些将来可能会迷失方向的人来说,这就是帮助我的地方.

So it took me longer than I like to admit to find the cause of this issue. But for anyone who might stumble over this in the future heres what helped me.

我将项目托管在IIS中所需站点下的两个子文件夹中. 因此,Desired_Site-> Subfolder1-> Subfolder2->实际项目文件. 我的猜测是IIS无法处理此位置中的web.config文件. 当我搬家

I hosted the project in two subfolders under the desired Site in IIS. So Desired_Site -> Subfolder1 -> Subfolder2 -> actual project files. My guess is that IIS couldn't handle the web.config file being in this location. When I moved

    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\MyApplication.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>

从项目web.config文件到Subolder1中的web.config(相应地调整路径),一切正常. 如果您遇到相同的问题,请确保要尝试托管的文件夹结构尽可能平坦.

from the projects web.config file to a web.config in Subolder1 (adjust paths accordingly) everything is working as expected. Should you run into the same problem make sure the folder structure you are trying to host under is as flat as possible.

这篇关于在IIS中托管.net Core应用程序.无法加载配置.属性'processPath'是必需的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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