简体   繁体   English

无法在 IIS 默认网站内托管带有 angular 的 ASP .NET 核心 3.1

[英]Not able to host ASP .NET core 3.1 with angular inside IIS default website

I am not able to host ASP.NET core 3.1 with an angular template app inside the IIS default website.我无法在 IIS 默认网站内使用 angular 模板应用程序托管 ASP.NET 核心 3.1。 The hosting works and angular app lanches if it is hosted as a standalone website in IIS.如果在 IIS 中作为独立网站托管,则托管工作和 angular 应用程序启动。 I have used default InProcess web hosting.我使用了默认的 InProcess web 托管。 But the same hosting fails to load when added inside the default website.但是在默认网站中添加相同的主机时无法加载。 Below error shown in the browser console tab:浏览器控制台选项卡中显示以下错误:

Failed to load resource: the server responded with a status of 404 (Not Found) runtime-es2015.c5fa8325f89fc516600b.js:1 Failed to load resource: the server responded with a status of 404 (Not Found) polyfills-es2015.7cfdeea462673f342285.js:1 Failed to load resource: the server responded with a status of 404 (Not Found) main-es2015.a7b9ab4b981098542774.js:1 Failed to load resource: the server responded with a status of 404 (Not Found) styles.747581a485d8163d58ca.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)加载资源失败:服务器响应状态为 404 (Not Found) runtime-es2015.c5fa8325f89fc516600b.js:1 加载资源失败:服务器响应状态为 404 (Not Found) polyfills-es2015.7cfdeea462673f342285.js :1 Failed to load resource: the server responded with a status of 404 (Not Found) main-es2015.a7b9ab4b981098542774.js:1 Failed to load resource: the server responded with a status of 404 (Not Found) styles.747581a485d8163d58ca.css :1 加载资源失败:服务器响应状态为 404(未找到)

My web.config looks as below:我的 web.config 如下所示:

 <?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="dotnet" arguments=".\XXXXX.dll" stdoutLogEnabled="false" 
      stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>

Is there anything that is needed extra in case of hosting it inside the default website?如果将其托管在默认网站中,是否需要额外的东西? This is strange as the same works if hosted independently.如果独立托管,这很奇怪,因为相同的作品。 I am not sure why it is not able to find angular resources inside the default website.我不确定为什么它无法在默认网站内找到 angular 资源。 I also tried adding a URL rewrite inside web.config but to my surprise that also did not work.我还尝试在 web.config 中添加 URL 重写,但令我惊讶的是这也不起作用。

To mention, .net core 3.1 runtime and the respective hosting bundle is installed on the machine.And app pool targets "no managed code".Nothing is getting logged via stdoutLogFile, so no clue what is happening.值得一提的是,.net 核心 3.1 运行时和相应的托管包已安装在机器上。应用程序池的目标是“无托管代码”。通过 stdoutLogFile 没有记录任何内容,所以不知道发生了什么。

For getting it to run as the default website, instead of having the files in C:\inetpub\wwwroot\TestWebApp put them in C:\inetpub\wwwroot\ , so C:\inetpub\wwwroot\ClientApp\dist . For getting it to run as the default website, instead of having the files in C:\inetpub\wwwroot\TestWebApp put them in C:\inetpub\wwwroot\ , so C:\inetpub\wwwroot\ClientApp\dist . This should fix the issue, the default website is looking for the files in wwwroot, not a subfolder.这应该可以解决问题,默认网站正在查找 wwwroot 中的文件,而不是子文件夹。

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

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